Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef ENABLE_BIOLOG_SYSTEM
- #include "../../common/service.h"
- #endif
- #include "stdafx.h"
- #include <stack>
- #include "utils.h"
- #include "config.h"
- #include "char.h"
- #include "char_manager.h"
- #include "item_manager.h"
- #include "desc.h"
- #include "desc_client.h"
- #include "desc_manager.h"
- #include "packet.h"
- #include "affect.h"
- #include "skill.h"
- #include "start_position.h"
- #include "mob_manager.h"
- #include "db.h"
- #include "log.h"
- #include "vector.h"
- #include "buffer_manager.h"
- #include "questmanager.h"
- #include "fishing.h"
- #include "party.h"
- #include "dungeon.h"
- #include "refine.h"
- #include "unique_item.h"
- #include "war_map.h"
- #include "xmas_event.h"
- #include "marriage.h"
- #include "monarch.h"
- #ifdef NEW_PET_SYSTEM
- #include "New_PetSystem.h"
- #endif
- #include "polymorph.h"
- #include "blend_item.h"
- #include "castle.h"
- #include "BattleArena.h"
- #include "arena.h"
- #include "dev_log.h"
- #include "pcbang.h"
- #include "threeway_war.h"
- #ifdef __ATTR_SWITCH_SYSTEM__
- #include "switchbot.h"
- #endif
- #include "safebox.h"
- #include "shop.h"
- #include "../../common/VnumHelper.h"
- #include "../../common/service.h"
- #include "DragonSoul.h"
- #include "biolog.h"
- #include "buff_on_attributes.h"
- #include "belt_inventory_helper.h"
- const int ITEM_BROKEN_METIN_VNUM = 28960;
- // CHANGE_ITEM_ATTRIBUTES
- const DWORD CHARACTER::msc_dwDefaultChangeItemAttrCycle = 10;
- const char CHARACTER::msc_szLastChangeItemAttrFlag[] = "Item.LastChangeItemAttr";
- const char CHARACTER::msc_szChangeItemAttrCycleFlag[] = "change_itemattr_cycle";
- // END_OF_CHANGE_ITEM_ATTRIBUTES
- const BYTE g_aBuffOnAttrPoints[] = { POINT_ENERGY, POINT_COSTUME_ATTR_BONUS };
- struct FFindStone
- {
- std::map<DWORD, LPCHARACTER> m_mapStone;
- void operator()(LPENTITY pEnt)
- {
- if (pEnt->IsType(ENTITY_CHARACTER) == true)
- {
- LPCHARACTER pChar = (LPCHARACTER)pEnt;
- if (pChar->IsStone() == true)
- {
- m_mapStone[(DWORD)pChar->GetVID()] = pChar;
- }
- }
- }
- };
- static bool IS_SUMMON_ITEM(int vnum)
- {
- switch (vnum)
- {
- case 22000:
- case 22010:
- case 22011:
- case 22020:
- case ITEM_MARRIAGE_RING:
- return true;
- }
- return false;
- }
- #ifdef BLOCK_ITEM_IN_MAP
- static bool IS_ENABLE_ITEM(int vnum)
- {
- switch (vnum)
- {
- case 71015:
- case 72049:
- case 72050:
- case 70005:
- case 39002:
- return true;
- }
- return false;
- }
- #endif
- static bool IS_MONKEY_DUNGEON(int map_index)
- {
- switch (map_index)
- {
- case 5:
- case 25:
- case 45:
- case 108:
- case 109:
- return true;;
- }
- return false;
- }
- bool IS_SUMMONABLE_ZONE(int map_index)
- {
- if (IS_MONKEY_DUNGEON(map_index))
- return false;
- if (IS_CASTLE_MAP(map_index))
- return false;
- switch (map_index)
- {
- case 66 :
- case 71 :
- case 72 :
- case 73 :
- case 193 :
- #if 0
- case 184 :
- case 185 :
- case 186 :
- case 187 :
- case 188 :
- case 189 :
- #endif
- // case 206 :
- case 216 :
- case 217 :
- case 208 :
- return false;
- }
- if (CBattleArena::IsBattleArenaMap(map_index)) return false;
- if (map_index > 10000) return false;
- return true;
- }
- #ifdef BLOCK_ITEM_IN_MAP
- bool IS_ENABLE_ITEM_ZONE(int map_index)
- {
- switch (map_index)
- {
- case 205:
- case 206:
- return false;
- }
- return true;
- }
- #endif
- bool IS_BOTARYABLE_ZONE(int nMapIndex)
- {
- if (LC_IsYMIR() == false && LC_IsKorea() == false) return true;
- switch (nMapIndex)
- {
- case 1 :
- case 3 :
- case 21 :
- case 23 :
- case 41 :
- case 43 :
- return true;
- }
- return false;
- }
- // item socket -- by mhh
- static bool FN_check_item_socket(LPITEM item)
- {
- for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
- {
- if (item->GetSocket(i) != item->GetProto()->alSockets[i])
- return false;
- }
- #ifdef ENABLE_SORT_INVENTORY
- if (item->GetType() == ITEM_USE && item->GetSubType() == USE_AFFECT)
- return true;
- #endif
- return true;
- }
- // item socket -- by mhh
- static void FN_copy_item_socket(LPITEM dest, LPITEM src)
- {
- for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
- {
- dest->SetSocket(i, src->GetSocket(i));
- }
- }
- static bool FN_check_item_sex(LPCHARACTER ch, LPITEM item)
- {
- //Man
- if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_MALE))
- {
- if (SEX_MALE==GET_SEX(ch))
- return false;
- }
- // Girl
- if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_FEMALE))
- {
- if (SEX_FEMALE==GET_SEX(ch))
- return false;
- }
- return true;
- }
- /////////////////////////////////////////////////////////////////////////////
- // ITEM HANDLING
- /////////////////////////////////////////////////////////////////////////////
- bool CHARACTER::CanHandleItem(bool bSkipCheckRefine, bool bSkipObserver)
- {
- if (!bSkipObserver)
- if (m_bIsObserver)
- return false;
- if (GetMyShop())
- return false;
- if (!bSkipCheckRefine)
- if (m_bUnderRefine)
- return false;
- if (IsCubeOpen() || NULL != DragonSoul_RefineWindow_GetOpener())
- return false;
- if (IsWarping())
- return false;
- #ifdef __SASH_SYSTEM__
- if ((m_bSashCombination) || (m_bSashAbsorption))
- return false;
- #endif
- return true;
- }
- LPITEM CHARACTER::GetInventoryItem(WORD wCell) const
- {
- return GetItem(TItemPos(INVENTORY, wCell));
- }
- #ifdef ENABLE_SPECIAL_STORAGE
- LPITEM CHARACTER::GetUpgradeInventoryItem(WORD wCell) const
- {
- return GetItem(TItemPos(UPGRADE_INVENTORY, wCell));
- }
- LPITEM CHARACTER::GetBookInventoryItem(WORD wCell) const
- {
- return GetItem(TItemPos(BOOK_INVENTORY, wCell));
- }
- LPITEM CHARACTER::GetStoneInventoryItem(WORD wCell) const
- {
- return GetItem(TItemPos(STONE_INVENTORY, wCell));
- }
- LPITEM CHARACTER::GetDndInventoryItem(WORD wCell) const
- {
- return GetItem(TItemPos(DND_INVENTORY, wCell));
- }
- LPITEM CHARACTER::GetGearInventoryItem(WORD wCell) const
- {
- return GetItem(TItemPos(GEAR_INVENTORY, wCell));
- }
- #endif
- LPITEM CHARACTER::GetItem(TItemPos Cell) const
- {
- if (!IsValidItemPosition(Cell))
- return NULL;
- WORD wCell = Cell.cell;
- BYTE window_type = Cell.window_type;
- switch (window_type)
- {
- case INVENTORY:
- case EQUIPMENT:
- if (wCell >= INVENTORY_AND_EQUIP_SLOT_MAX)
- {
- sys_err("CHARACTER::GetInventoryItem: invalid item cell %d", wCell);
- return NULL;
- }
- return m_pointsInstant.pItems[wCell];
- case DRAGON_SOUL_INVENTORY:
- if (wCell >= DRAGON_SOUL_INVENTORY_MAX_NUM)
- {
- sys_err("CHARACTER::GetInventoryItem: invalid DS item cell %d", wCell);
- return NULL;
- }
- return m_pointsInstant.pDSItems[wCell];
- #ifdef __ATTR_SWITCH_SYSTEM__
- case SWITCHBOT:
- if (wCell >= SWITCHBOT_SLOT_COUNT)
- {
- sys_err("CHARACTER::GetInventoryItem: invalid switchbot item cell %d", wCell);
- return NULL;
- }
- return m_pointsInstant.pSwitchbotItems[wCell];
- #endif
- #ifdef ENABLE_SPECIAL_STORAGE
- case UPGRADE_INVENTORY:
- if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
- {
- sys_err("CHARACTER::GetInventoryItem: invalid SSU item cell %d", wCell);
- return NULL;
- }
- return m_pointsInstant.pSSUItems[wCell];
- case BOOK_INVENTORY:
- if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
- {
- sys_err("CHARACTER::GetInventoryItem: invalid SSB item cell %d", wCell);
- return NULL;
- }
- return m_pointsInstant.pSSBItems[wCell];
- case STONE_INVENTORY:
- if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
- {
- sys_err("CHARACTER::GetInventoryItem: invalid SSS item cell %d", wCell);
- return NULL;
- }
- return m_pointsInstant.pSSSItems[wCell];
- case DND_INVENTORY:
- if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
- {
- sys_err("CHARACTER::GetInventoryItem: invalid SSD item cell %d", wCell);
- return NULL;
- }
- return m_pointsInstant.pSSDItems[wCell];
- case GEAR_INVENTORY:
- if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
- {
- sys_err("CHARACTER::GetInventoryItem: invalid SSG item cell %d", wCell);
- return NULL;
- }
- return m_pointsInstant.pSSGItems[wCell];
- #endif
- default:
- return NULL;
- }
- return NULL;
- }
- #ifdef ENABLE_HIGHLIGHT_NEW_ITEM
- void CHARACTER::SetItem(TItemPos Cell, LPITEM pItem, bool bWereMine)
- #else
- void CHARACTER::SetItem(TItemPos Cell, LPITEM pItem)
- #endif
- {
- WORD wCell = Cell.cell;
- BYTE window_type = Cell.window_type;
- if ((unsigned long)((CItem*)pItem) == 0xff || (unsigned long)((CItem*)pItem) == 0xffffffff)
- {
- sys_err("!!! FATAL ERROR !!! item == 0xff (char: %s cell: %u)", GetName(), wCell);
- core_dump();
- return;
- }
- if (pItem && pItem->GetOwner())
- {
- assert(!"GetOwner exist");
- return;
- }
- switch(window_type)
- {
- case INVENTORY:
- case EQUIPMENT:
- {
- if (wCell >= INVENTORY_AND_EQUIP_SLOT_MAX)
- {
- sys_err("CHARACTER::SetItem: invalid item cell %d", wCell);
- return;
- }
- LPITEM pOld = m_pointsInstant.pItems[wCell];
- if (pOld)
- {
- if (wCell < INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pOld->GetSize(); ++i)
- {
- int p = wCell + (i * 5);
- if (p >= INVENTORY_MAX_NUM)
- continue;
- if (m_pointsInstant.pItems[p] && m_pointsInstant.pItems[p] != pOld)
- continue;
- m_pointsInstant.bItemGrid[p] = 0;
- }
- }
- else
- m_pointsInstant.bItemGrid[wCell] = 0;
- }
- if (pItem)
- {
- if (wCell < INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pItem->GetSize(); ++i)
- {
- int p = wCell + (i * 5);
- if (p >= INVENTORY_MAX_NUM)
- continue;
- m_pointsInstant.bItemGrid[p] = wCell + 1;
- }
- }
- else
- m_pointsInstant.bItemGrid[wCell] = wCell + 1;
- }
- m_pointsInstant.pItems[wCell] = pItem;
- }
- break;
- // ¿ëÈ¥¼® Àκ¥Å丮
- case DRAGON_SOUL_INVENTORY:
- {
- LPITEM pOld = m_pointsInstant.pDSItems[wCell];
- if (pOld)
- {
- if (wCell < DRAGON_SOUL_INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pOld->GetSize(); ++i)
- {
- int p = wCell + (i * DRAGON_SOUL_BOX_COLUMN_NUM);
- if (p >= DRAGON_SOUL_INVENTORY_MAX_NUM)
- continue;
- if (m_pointsInstant.pDSItems[p] && m_pointsInstant.pDSItems[p] != pOld)
- continue;
- m_pointsInstant.wDSItemGrid[p] = 0;
- }
- }
- else
- m_pointsInstant.wDSItemGrid[wCell] = 0;
- }
- if (pItem)
- {
- if (wCell >= DRAGON_SOUL_INVENTORY_MAX_NUM)
- {
- sys_err("CHARACTER::SetItem: invalid DS item cell %d", wCell);
- return;
- }
- if (wCell < DRAGON_SOUL_INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pItem->GetSize(); ++i)
- {
- int p = wCell + (i * DRAGON_SOUL_BOX_COLUMN_NUM);
- if (p >= DRAGON_SOUL_INVENTORY_MAX_NUM)
- continue;
- m_pointsInstant.wDSItemGrid[p] = wCell + 1;
- }
- }
- else
- m_pointsInstant.wDSItemGrid[wCell] = wCell + 1;
- }
- m_pointsInstant.pDSItems[wCell] = pItem;
- }
- break;
- #ifdef __ATTR_SWITCH_SYSTEM__
- case SWITCHBOT:
- {
- LPITEM pOld = m_pointsInstant.pSwitchbotItems[wCell];
- if (pItem && pOld)
- return;
- if (wCell >= SWITCHBOT_SLOT_COUNT)
- {
- sys_err("CHARACTER::SetItem: invalid switchbot item cell %d", wCell);
- return;
- }
- if (pItem)
- CSwitchbotManager::Instance().RegisterItem(GetPlayerID(), pItem->GetID(), wCell);
- else
- CSwitchbotManager::Instance().UnregisterItem(GetPlayerID(), wCell);
- m_pointsInstant.pSwitchbotItems[wCell] = pItem;
- }
- break;
- #endif
- #ifdef ENABLE_SPECIAL_STORAGE
- case UPGRADE_INVENTORY:
- {
- LPITEM pOld = m_pointsInstant.pSSUItems[wCell];
- if (pOld)
- {
- if (wCell < SPECIAL_INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pOld->GetSize(); ++i)
- {
- int p = wCell + (i * 5);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- continue;
- if (m_pointsInstant.pSSUItems[p] && m_pointsInstant.pSSUItems[p] != pOld)
- continue;
- m_pointsInstant.wSSUItemGrid[p] = 0;
- }
- }
- else
- m_pointsInstant.wSSUItemGrid[wCell] = 0;
- }
- if (pItem)
- {
- if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
- {
- sys_err("CHARACTER::SetItem: invalid SSU item cell %d", wCell);
- return;
- }
- if (wCell < SPECIAL_INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pItem->GetSize(); ++i)
- {
- int p = wCell + (i * 5);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- continue;
- m_pointsInstant.wSSUItemGrid[p] = wCell + 1;
- }
- }
- else
- m_pointsInstant.wSSUItemGrid[wCell] = wCell + 1;
- }
- m_pointsInstant.pSSUItems[wCell] = pItem;
- }
- break;
- case BOOK_INVENTORY:
- {
- LPITEM pOld = m_pointsInstant.pSSBItems[wCell];
- if (pOld)
- {
- if (wCell < SPECIAL_INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pOld->GetSize(); ++i)
- {
- int p = wCell + (i * 5);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- continue;
- if (m_pointsInstant.pSSBItems[p] && m_pointsInstant.pSSBItems[p] != pOld)
- continue;
- m_pointsInstant.wSSBItemGrid[p] = 0;
- }
- }
- else
- m_pointsInstant.wSSBItemGrid[wCell] = 0;
- }
- if (pItem)
- {
- if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
- {
- sys_err("CHARACTER::SetItem: invalid SSB item cell %d", wCell);
- return;
- }
- if (wCell < SPECIAL_INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pItem->GetSize(); ++i)
- {
- int p = wCell + (i * 5);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- continue;
- m_pointsInstant.wSSBItemGrid[p] = wCell + 1;
- }
- }
- else
- m_pointsInstant.wSSBItemGrid[wCell] = wCell + 1;
- }
- m_pointsInstant.pSSBItems[wCell] = pItem;
- }
- break;
- case STONE_INVENTORY:
- {
- LPITEM pOld = m_pointsInstant.pSSSItems[wCell];
- if (pOld)
- {
- if (wCell < SPECIAL_INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pOld->GetSize(); ++i)
- {
- int p = wCell + (i * 5);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- continue;
- if (m_pointsInstant.pSSSItems[p] && m_pointsInstant.pSSSItems[p] != pOld)
- continue;
- m_pointsInstant.wSSSItemGrid[p] = 0;
- }
- }
- else
- m_pointsInstant.wSSSItemGrid[wCell] = 0;
- }
- if (pItem)
- {
- if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
- {
- sys_err("CHARACTER::SetItem: invalid SSB item cell %d", wCell);
- return;
- }
- if (wCell < SPECIAL_INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pItem->GetSize(); ++i)
- {
- int p = wCell + (i * 5);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- continue;
- m_pointsInstant.wSSSItemGrid[p] = wCell + 1;
- }
- }
- else
- m_pointsInstant.wSSSItemGrid[wCell] = wCell + 1;
- }
- m_pointsInstant.pSSSItems[wCell] = pItem;
- }
- break;
- case DND_INVENTORY:
- {
- LPITEM pOld = m_pointsInstant.pSSDItems[wCell];
- if (pOld)
- {
- if (wCell < SPECIAL_INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pOld->GetSize(); ++i)
- {
- int p = wCell + (i * 5);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- continue;
- if (m_pointsInstant.pSSDItems[p] && m_pointsInstant.pSSDItems[p] != pOld)
- continue;
- m_pointsInstant.wSSDItemGrid[p] = 0;
- }
- }
- else
- m_pointsInstant.wSSDItemGrid[wCell] = 0;
- }
- if (pItem)
- {
- if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
- {
- sys_err("CHARACTER::SetItem: invalid SSD item cell %d", wCell);
- return;
- }
- if (wCell < SPECIAL_INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pItem->GetSize(); ++i)
- {
- int p = wCell + (i * 5);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- continue;
- m_pointsInstant.wSSDItemGrid[p] = wCell + 1;
- }
- }
- else
- m_pointsInstant.wSSDItemGrid[wCell] = wCell + 1;
- }
- m_pointsInstant.pSSDItems[wCell] = pItem;
- }
- break;
- case GEAR_INVENTORY:
- {
- LPITEM pOld = m_pointsInstant.pSSGItems[wCell];
- if (pOld)
- {
- if (wCell < SPECIAL_INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pOld->GetSize(); ++i)
- {
- int p = wCell + (i * 5);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- continue;
- if (m_pointsInstant.pSSGItems[p] && m_pointsInstant.pSSGItems[p] != pOld)
- continue;
- m_pointsInstant.wSSGItemGrid[p] = 0;
- }
- }
- else
- m_pointsInstant.wSSGItemGrid[wCell] = 0;
- }
- if (pItem)
- {
- if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
- {
- sys_err("CHARACTER::SetItem: invalid SSG item cell %d", wCell);
- return;
- }
- if (wCell < SPECIAL_INVENTORY_MAX_NUM)
- {
- for (int i = 0; i < pItem->GetSize(); ++i)
- {
- int p = wCell + (i * 5);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- continue;
- m_pointsInstant.wSSGItemGrid[p] = wCell + 1;
- }
- }
- else
- m_pointsInstant.wSSGItemGrid[wCell] = wCell + 1;
- }
- m_pointsInstant.pSSGItems[wCell] = pItem;
- }
- break;
- #endif
- default:
- sys_err ("Invalid Inventory type %d", window_type);
- return;
- }
- if (GetDesc())
- {
- if (pItem)
- {
- TPacketGCItemSet pack;
- pack.header = HEADER_GC_ITEM_SET;
- pack.Cell = Cell;
- pack.count = pItem->GetCount();
- pack.vnum = pItem->GetVnum();
- pack.flags = pItem->GetFlag();
- pack.anti_flags = pItem->GetAntiFlag();
- #ifdef ENABLE_HIGHLIGHT_NEW_ITEM
- pack.highlight = !bWereMine || (Cell.window_type == DRAGON_SOUL_INVENTORY);(Cell.window_type == DRAGON_SOUL_INVENTORY);
- #else
- pack.highlight = (Cell.window_type == DRAGON_SOUL_INVENTORY);
- #endif
- thecore_memcpy(pack.alSockets, pItem->GetSockets(), sizeof(pack.alSockets));
- thecore_memcpy(pack.aAttr, pItem->GetAttributes(), sizeof(pack.aAttr));
- GetDesc()->Packet(&pack, sizeof(TPacketGCItemSet));
- }
- else
- {
- TPacketGCItemDelDeprecated pack;
- pack.header = HEADER_GC_ITEM_DEL;
- pack.Cell = Cell;
- pack.count = 0;
- pack.vnum = 0;
- memset(pack.alSockets, 0, sizeof(pack.alSockets));
- memset(pack.aAttr, 0, sizeof(pack.aAttr));
- GetDesc()->Packet(&pack, sizeof(TPacketGCItemDelDeprecated));
- }
- }
- if (pItem)
- {
- pItem->SetCell(this, wCell);
- switch (window_type)
- {
- case INVENTORY:
- case EQUIPMENT:
- if ((wCell < INVENTORY_MAX_NUM) || (BELT_INVENTORY_SLOT_START <= wCell && BELT_INVENTORY_SLOT_END > wCell))
- pItem->SetWindow(INVENTORY);
- else
- pItem->SetWindow(EQUIPMENT);
- break;
- case DRAGON_SOUL_INVENTORY:
- pItem->SetWindow(DRAGON_SOUL_INVENTORY);
- break;
- #ifdef __ATTR_SWITCH_SYSTEM__
- case SWITCHBOT:
- pItem->SetWindow(SWITCHBOT);
- break;
- #endif
- #ifdef ENABLE_SPECIAL_STORAGE
- case UPGRADE_INVENTORY:
- pItem->SetWindow(UPGRADE_INVENTORY);
- break;
- case BOOK_INVENTORY:
- pItem->SetWindow(BOOK_INVENTORY);
- break;
- case STONE_INVENTORY:
- pItem->SetWindow(STONE_INVENTORY);
- break;
- case DND_INVENTORY:
- pItem->SetWindow(DND_INVENTORY);
- break;
- case GEAR_INVENTORY:
- pItem->SetWindow(GEAR_INVENTORY);
- break;
- #endif
- }
- }
- }
- LPITEM CHARACTER::GetWear(BYTE bCell) const
- {
- // > WEAR_MAX_NUM
- if (bCell >= WEAR_MAX_NUM + DRAGON_SOUL_DECK_MAX_NUM * DS_SLOT_MAX)
- {
- sys_err("CHARACTER::GetWear: invalid wear cell %d", bCell);
- return NULL;
- }
- return m_pointsInstant.pItems[INVENTORY_MAX_NUM + bCell];
- }
- void CHARACTER::SetWear(BYTE bCell, LPITEM item)
- {
- // > WEAR_MAX_NUM :
- if (bCell >= WEAR_MAX_NUM + DRAGON_SOUL_DECK_MAX_NUM * DS_SLOT_MAX)
- {
- sys_err("CHARACTER::SetItem: invalid item cell %d", bCell);
- return;
- }
- SetItem(TItemPos (INVENTORY, INVENTORY_MAX_NUM + bCell), item);
- if (!item && bCell == WEAR_WEAPON)
- {
- if (IsAffectFlag(AFF_GWIGUM))
- RemoveAffect(SKILL_GWIGEOM);
- if (IsAffectFlag(AFF_GEOMGYEONG))
- RemoveAffect(SKILL_GEOMKYUNG);
- }
- }
- void CHARACTER::ClearItem()
- {
- int i;
- LPITEM item;
- for (i = 0; i < INVENTORY_AND_EQUIP_SLOT_MAX; ++i)
- {
- if ((item = GetInventoryItem(i)))
- {
- item->SetSkipSave(true);
- ITEM_MANAGER::instance().FlushDelayedSave(item);
- item->RemoveFromCharacter();
- M2_DESTROY_ITEM(item);
- SyncQuickslot(QUICKSLOT_TYPE_ITEM, i, 255);
- }
- }
- for (i = 0; i < DRAGON_SOUL_INVENTORY_MAX_NUM; ++i)
- {
- if ((item = GetItem(TItemPos(DRAGON_SOUL_INVENTORY, i))))
- {
- item->SetSkipSave(true);
- ITEM_MANAGER::instance().FlushDelayedSave(item);
- item->RemoveFromCharacter();
- M2_DESTROY_ITEM(item);
- }
- }
- #ifdef __ATTR_SWITCH_SYSTEM__
- for (i = 0; i < SWITCHBOT_SLOT_COUNT; ++i)
- {
- if ((item = GetItem(TItemPos(SWITCHBOT, i))))
- {
- item->SetSkipSave(true);
- ITEM_MANAGER::instance().FlushDelayedSave(item);
- item->RemoveFromCharacter();
- M2_DESTROY_ITEM(item);
- }
- }
- #endif
- #ifdef ENABLE_SPECIAL_STORAGE
- for (i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- if ((item = GetItem(TItemPos(UPGRADE_INVENTORY, i))))
- {
- item->SetSkipSave(true);
- ITEM_MANAGER::instance().FlushDelayedSave(item);
- item->RemoveFromCharacter();
- M2_DESTROY_ITEM(item);
- }
- }
- for (i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- if ((item = GetItem(TItemPos(BOOK_INVENTORY, i))))
- {
- item->SetSkipSave(true);
- ITEM_MANAGER::instance().FlushDelayedSave(item);
- item->RemoveFromCharacter();
- M2_DESTROY_ITEM(item);
- }
- }
- for (i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- if ((item = GetItem(TItemPos(STONE_INVENTORY, i))))
- {
- item->SetSkipSave(true);
- ITEM_MANAGER::instance().FlushDelayedSave(item);
- item->RemoveFromCharacter();
- M2_DESTROY_ITEM(item);
- }
- }
- for (i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- if ((item = GetItem(TItemPos(DND_INVENTORY, i))))
- {
- item->SetSkipSave(true);
- ITEM_MANAGER::instance().FlushDelayedSave(item);
- item->RemoveFromCharacter();
- M2_DESTROY_ITEM(item);
- }
- }
- for (i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- if ((item = GetItem(TItemPos(GEAR_INVENTORY, i))))
- {
- item->SetSkipSave(true);
- ITEM_MANAGER::instance().FlushDelayedSave(item);
- item->RemoveFromCharacter();
- M2_DESTROY_ITEM(item);
- }
- }
- #endif
- }
- bool CHARACTER::IsEmptyItemGrid(TItemPos Cell, BYTE bSize, int iExceptionCell) const
- {
- switch (Cell.window_type)
- {
- case INVENTORY:
- {
- BYTE bCell = Cell.cell;
- ++iExceptionCell;
- if (Cell.IsBeltInventoryPosition())
- {
- LPITEM beltItem = GetWear(WEAR_BELT);
- if (NULL == beltItem)
- return false;
- if (false == CBeltInventoryHelper::IsAvailableCell(bCell - BELT_INVENTORY_SLOT_START, beltItem->GetValue(0)))
- return false;
- if (m_pointsInstant.bItemGrid[bCell])
- {
- if (m_pointsInstant.bItemGrid[bCell] == iExceptionCell)
- return true;
- return false;
- }
- if (bSize == 1)
- return true;
- }
- else if (bCell >= INVENTORY_MAX_NUM)
- return false;
- if (m_pointsInstant.bItemGrid[bCell])
- {
- if (m_pointsInstant.bItemGrid[bCell] == iExceptionCell)
- {
- if (bSize == 1)
- return true;
- int j = 1;
- BYTE bPage = bCell / (INVENTORY_MAX_NUM / 4);
- do
- {
- BYTE p = bCell + (5 * j);
- if (p >= INVENTORY_MAX_NUM)
- return false;
- if (p / (INVENTORY_MAX_NUM / 4) != bPage)
- return false;
- if (m_pointsInstant.bItemGrid[p])
- if (m_pointsInstant.bItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- else
- return false;
- }
- if (1 == bSize)
- return true;
- else
- {
- int j = 1;
- BYTE bPage = bCell / (INVENTORY_MAX_NUM / 4);
- do
- {
- BYTE p = bCell + (5 * j);
- if (p >= INVENTORY_MAX_NUM)
- return false;
- if (p / (INVENTORY_MAX_NUM / 4) != bPage)
- return false;
- if (m_pointsInstant.bItemGrid[p])
- if (m_pointsInstant.bItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- }
- break;
- #ifdef ENABLE_SPECIAL_STORAGE
- case UPGRADE_INVENTORY:
- {
- WORD bCell = Cell.cell;
- iExceptionCell++;
- if (bCell >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- if (m_pointsInstant.wSSUItemGrid[bCell])
- {
- if (m_pointsInstant.wSSUItemGrid[bCell] == iExceptionCell)
- {
- if (bSize == 1)
- return true;
- int j = 1;
- BYTE bPage = bCell / (SPECIAL_INVENTORY_MAX_NUM / 4);
- do
- {
- BYTE p = bCell + (5 * j);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- if (p / (SPECIAL_INVENTORY_MAX_NUM / 4) != bPage)
- return false;
- if (m_pointsInstant.wSSUItemGrid[p])
- if (m_pointsInstant.wSSUItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- else
- return false;
- }
- if (1 == bSize)
- return true;
- else
- {
- int j = 1;
- BYTE bPage = bCell / (SPECIAL_INVENTORY_MAX_NUM / 4);
- do
- {
- int p = bCell + (5 * j);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- if (p / (SPECIAL_INVENTORY_MAX_NUM / 4) != bPage)
- return false;
- if (m_pointsInstant.wSSUItemGrid[p])
- if (m_pointsInstant.wSSUItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- }
- break;
- case BOOK_INVENTORY:
- {
- WORD bCell = Cell.cell;
- iExceptionCell++;
- if (bCell >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- if (m_pointsInstant.wSSBItemGrid[bCell])
- {
- if (m_pointsInstant.wSSBItemGrid[bCell] == iExceptionCell)
- {
- if (bSize == 1)
- return true;
- int j = 1;
- BYTE bPage = bCell / (SPECIAL_INVENTORY_MAX_NUM / 4);
- do
- {
- int p = bCell + (5 * j);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- if (p / (SPECIAL_INVENTORY_MAX_NUM / 4) != bPage)
- return false;
- if (m_pointsInstant.wSSBItemGrid[p])
- if (m_pointsInstant.wSSBItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- else
- return false;
- }
- if (1 == bSize)
- return true;
- else
- {
- int j = 1;
- BYTE bPage = bCell / (SPECIAL_INVENTORY_MAX_NUM / 4);
- do
- {
- int p = bCell + (5 * j);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- if (p / (SPECIAL_INVENTORY_MAX_NUM / 4) != bPage)
- return false;
- if (m_pointsInstant.wSSBItemGrid[p])
- if (m_pointsInstant.wSSBItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- }
- case STONE_INVENTORY:
- {
- WORD bCell = Cell.cell;
- iExceptionCell++;
- if (bCell >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- if (m_pointsInstant.wSSSItemGrid[bCell])
- {
- if (m_pointsInstant.wSSSItemGrid[bCell] == iExceptionCell)
- {
- if (bSize == 1)
- return true;
- int j = 1;
- BYTE bPage = bCell / (SPECIAL_INVENTORY_MAX_NUM / 4);
- do
- {
- int p = bCell + (5 * j);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- if (p / (SPECIAL_INVENTORY_MAX_NUM / 4) != bPage)
- return false;
- if (m_pointsInstant.wSSSItemGrid[p])
- if (m_pointsInstant.wSSSItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- else
- return false;
- }
- if (1 == bSize)
- return true;
- else
- {
- int j = 1;
- BYTE bPage = bCell / (SPECIAL_INVENTORY_MAX_NUM / 4);
- do
- {
- int p = bCell + (5 * j);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- if (p / (SPECIAL_INVENTORY_MAX_NUM / 4) != bPage)
- return false;
- if (m_pointsInstant.wSSSItemGrid[p])
- if (m_pointsInstant.wSSSItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- }
- break;
- case DND_INVENTORY:
- {
- WORD wCell = Cell.cell;
- if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- iExceptionCell++;
- if (m_pointsInstant.wSSDItemGrid[wCell])
- {
- if (m_pointsInstant.wSSDItemGrid[wCell] == iExceptionCell)
- {
- if (bSize == 1)
- return true;
- int j = 1;
- do
- {
- int p = wCell + (5 * j);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- if (m_pointsInstant.wSSDItemGrid[p])
- if (m_pointsInstant.wSSDItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- else
- return false;
- }
- if (1 == bSize)
- return true;
- else
- {
- int j = 1;
- do
- {
- int p = wCell + (5 * j);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- if (m_pointsInstant.bItemGrid[p]) // old bItemGrid
- if (m_pointsInstant.wSSDItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- }
- case GEAR_INVENTORY:
- {
- WORD wCell = Cell.cell;
- if (wCell >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- iExceptionCell++;
- if (m_pointsInstant.wSSGItemGrid[wCell])
- {
- if (m_pointsInstant.wSSGItemGrid[wCell] == iExceptionCell)
- {
- if (bSize == 1)
- return true;
- int j = 1;
- do
- {
- int p = wCell + (5 * j);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- if (m_pointsInstant.wSSGItemGrid[p])
- if (m_pointsInstant.wSSGItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- else
- return false;
- }
- if (1 == bSize)
- return true;
- else
- {
- int j = 1;
- do
- {
- int p = wCell + (5 * j);
- if (p >= SPECIAL_INVENTORY_MAX_NUM)
- return false;
- if (m_pointsInstant.bItemGrid[p]) // old bItemGrid
- if (m_pointsInstant.wSSGItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- }
- #endif
- case DRAGON_SOUL_INVENTORY:
- {
- WORD wCell = Cell.cell;
- if (wCell >= DRAGON_SOUL_INVENTORY_MAX_NUM)
- return false;
- iExceptionCell++;
- if (m_pointsInstant.wDSItemGrid[wCell])
- {
- if (m_pointsInstant.wDSItemGrid[wCell] == iExceptionCell)
- {
- if (bSize == 1)
- return true;
- int j = 1;
- do
- {
- int p = wCell + (DRAGON_SOUL_BOX_COLUMN_NUM * j);
- if (p >= DRAGON_SOUL_INVENTORY_MAX_NUM)
- return false;
- if (m_pointsInstant.wDSItemGrid[p])
- if (m_pointsInstant.wDSItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- else
- return false;
- }
- if (1 == bSize)
- return true;
- else
- {
- int j = 1;
- do
- {
- int p = wCell + (DRAGON_SOUL_BOX_COLUMN_NUM * j);
- if (p >= DRAGON_SOUL_INVENTORY_MAX_NUM)
- return false;
- if (m_pointsInstant.bItemGrid[p])
- if (m_pointsInstant.wDSItemGrid[p] != iExceptionCell)
- return false;
- }
- while (++j < bSize);
- return true;
- }
- }
- break;
- #ifdef __ATTR_SWITCH_SYSTEM__
- case SWITCHBOT:
- {
- WORD wCell = Cell.cell;
- if (wCell >= SWITCHBOT_SLOT_COUNT)
- return false;
- if (m_pointsInstant.pSwitchbotItems[wCell])
- return false;
- return true;
- }
- break;
- #endif
- }
- }
- int CHARACTER::GetEmptyInventory(BYTE size) const
- {
- for ( int i = 0; i < INVENTORY_MAX_NUM; ++i)
- if (IsEmptyItemGrid(TItemPos (INVENTORY, i), size))
- return i;
- return -1;
- }
- int CHARACTER::GetEmptyDragonSoulInventory(LPITEM pItem) const
- {
- if (NULL == pItem || !pItem->IsDragonSoul())
- return -1;
- if (!DragonSoul_IsQualified())
- {
- return -1;
- }
- BYTE bSize = pItem->GetSize();
- WORD wBaseCell = DSManager::instance().GetBasePosition(pItem);
- if (WORD_MAX == wBaseCell)
- return -1;
- for (int i = 0; i < DRAGON_SOUL_BOX_SIZE; ++i)
- if (IsEmptyItemGrid(TItemPos(DRAGON_SOUL_INVENTORY, i + wBaseCell), bSize))
- return i + wBaseCell;
- return -1;
- }
- void CHARACTER::CopyDragonSoulItemGrid(std::vector<WORD>& vDragonSoulItemGrid) const
- {
- vDragonSoulItemGrid.resize(DRAGON_SOUL_INVENTORY_MAX_NUM);
- std::copy(m_pointsInstant.wDSItemGrid, m_pointsInstant.wDSItemGrid + DRAGON_SOUL_INVENTORY_MAX_NUM, vDragonSoulItemGrid.begin());
- }
- #ifdef ENABLE_SPECIAL_STORAGE
- int CHARACTER::GetEmptyUpgradeInventory(LPITEM pItem) const
- {
- if (NULL == pItem || !pItem->IsUpgradeItem())
- return -1;
- BYTE bSize = pItem->GetSize();
- for ( int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- if (IsEmptyItemGrid(TItemPos (UPGRADE_INVENTORY, i), bSize))
- return i;
- return -1;
- }
- int CHARACTER::GetEmptyBookInventory(LPITEM pItem) const
- {
- if (NULL == pItem || !pItem->IsBook())
- return -1;
- BYTE bSize = pItem->GetSize();
- for ( int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- if (IsEmptyItemGrid(TItemPos (BOOK_INVENTORY, i), bSize))
- return i;
- return -1;
- }
- int CHARACTER::GetEmptyStoneInventory(LPITEM pItem) const
- {
- if (NULL == pItem || !pItem->IsStone())
- return -1;
- BYTE bSize = pItem->GetSize();
- for ( int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- if (IsEmptyItemGrid(TItemPos (STONE_INVENTORY, i), bSize))
- return i;
- return -1;
- }
- int CHARACTER::GetEmptyDndInventory(LPITEM pItem) const
- {
- if (NULL == pItem || !pItem->IsDnd())
- return -1;
- BYTE bSize = pItem->GetSize();
- for ( int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- if (IsEmptyItemGrid(TItemPos (DND_INVENTORY, i), bSize))
- return i;
- return -1;
- }
- int CHARACTER::GetEmptyGearInventory(LPITEM pItem) const
- {
- if (NULL == pItem || !pItem->IsGear())
- return -1;
- BYTE bSize = pItem->GetSize();
- for ( int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- if (IsEmptyItemGrid(TItemPos (GEAR_INVENTORY, i), bSize))
- return i;
- return -1;
- }
- #endif
- int CHARACTER::CountEmptyInventory() const
- {
- int count = 0;
- for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
- if (GetInventoryItem(i))
- count += GetInventoryItem(i)->GetSize();
- return (INVENTORY_MAX_NUM - count);
- }
- void TransformRefineItem(LPITEM pkOldItem, LPITEM pkNewItem)
- {
- // ACCESSORY_REFINE
- if (pkOldItem->IsAccessoryForSocket())
- {
- for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
- {
- pkNewItem->SetSocket(i, pkOldItem->GetSocket(i));
- }
- //pkNewItem->StartAccessorySocketExpireEvent();
- }
- // END_OF_ACCESSORY_REFINE
- else
- {
- for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
- {
- if (!pkOldItem->GetSocket(i))
- break;
- else
- pkNewItem->SetSocket(i, 1);
- }
- int slot = 0;
- for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
- {
- long socket = pkOldItem->GetSocket(i);
- if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
- pkNewItem->SetSocket(slot++, socket);
- }
- }
- pkOldItem->CopyAttributeTo(pkNewItem);
- }
- void NotifyRefineSuccess(LPCHARACTER ch, LPITEM item, const char* way)
- {
- if (NULL != ch && item != NULL)
- {
- ch->ChatPacket(CHAT_TYPE_COMMAND, "RefineSuceeded");
- LogManager::instance().RefineLog(ch->GetPlayerID(), item->GetName(), item->GetID(), item->GetRefineLevel(), 1, way);
- }
- }
- void NotifyRefineFail(LPCHARACTER ch, LPITEM item, const char* way, int success = 0)
- {
- if (NULL != ch && NULL != item)
- {
- ch->ChatPacket(CHAT_TYPE_COMMAND, "RefineFailed");
- LogManager::instance().RefineLog(ch->GetPlayerID(), item->GetName(), item->GetID(), item->GetRefineLevel(), success, way);
- }
- }
- void CHARACTER::SetRefineNPC(LPCHARACTER ch)
- {
- if ( ch != NULL )
- {
- m_dwRefineNPCVID = ch->GetVID();
- }
- else
- {
- m_dwRefineNPCVID = 0;
- }
- }
- bool CHARACTER::DoRefine(LPITEM item, bool bMoneyOnly)
- {
- if (!CanHandleItem(true))
- {
- ClearRefineMode();
- return false;
- }
- if (quest::CQuestManager::instance().GetEventFlag("update_refine_time") != 0)
- {
- if (get_global_time() < quest::CQuestManager::instance().GetEventFlag("update_refine_time") + (60 * 5))
- {
- sys_log(0, "can't refine %d %s", GetPlayerID(), GetName());
- return false;
- }
- }
- const TRefineTable * prt = CRefineManager::instance().GetRefineRecipe(item->GetRefineSet());
- if (!prt)
- return false;
- DWORD result_vnum = item->GetRefinedVnum();
- // REFINE_COST
- int cost = ComputeRefineFee(prt->cost);
- int RefineChance = GetQuestFlag("main_quest_lv7.refine_chance");
- if (RefineChance > 0)
- {
- if (!item->CheckItemUseLevel(20) || item->GetType() != ITEM_WEAPON)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Upgrade gratuit de la nivel 20"));
- return false;
- }
- cost = 0;
- SetQuestFlag("main_quest_lv7.refine_chance", RefineChance - 1);
- }
- // END_OF_REFINE_COST
- if (result_vnum == 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poate fi inbunatatit."));
- return false;
- }
- if (item->GetType() == ITEM_USE && item->GetSubType() == USE_TUNING)
- return false;
- TItemTable * pProto = ITEM_MANAGER::instance().GetTable(item->GetRefinedVnum());
- if (!pProto)
- {
- sys_err("DoRefine NOT GET ITEM PROTO %d", item->GetRefinedVnum());
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
- return false;
- }
- // REFINE_COST
- if (GetGold() < cost)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai destui bani pentru upgrade."));
- return false;
- }
- if (!bMoneyOnly && !RefineChance)
- {
- for (int i = 0; i < prt->material_count; ++i)
- {
- if (CountSpecifyItem(prt->materials[i].vnum) < prt->materials[i].count)
- {
- if (test_server)
- {
- ChatPacket(CHAT_TYPE_INFO, "Find %d, count %d, require %d", prt->materials[i].vnum, CountSpecifyItem(prt->materials[i].vnum), prt->materials[i].count);
- }
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai materialele necesare."));
- return false;
- }
- }
- for (int i = 0; i < prt->material_count; ++i)
- RemoveSpecifyItem(prt->materials[i].vnum, prt->materials[i].count);
- }
- int prob = number(1, 100);
- #ifdef ENABLE_FEATURES_REFINE_SYSTEM
- if (IsRefineThroughGuild())
- {
- prob -= 10;
- }
- int success_prob = prt->prob;
- success_prob += CRefineManager::instance().Result(this);
- #else
- if (IsRefineThroughGuild())
- prob -= 10;
- #endif
- // END_OF_REFINE_COST
- #ifdef ENABLE_FEATURES_REFINE_SYSTEM
- if (prob <= success_prob)
- #else
- if (prob <= prt->prob)
- #endif
- {
- LPITEM pkNewItem = ITEM_MANAGER::instance().CreateItem(result_vnum, 1, 0, false);
- if (pkNewItem)
- {
- ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
- LogManager::instance().ItemLog(this, pkNewItem, "REFINE SUCCESS", pkNewItem->GetName());
- BYTE bCell = item->GetCell();
- // DETAIL_REFINE_LOG
- NotifyRefineSuccess(this, item, IsRefineThroughGuild() ? "GUILD" : "POWER");
- DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, item->GetVnum(), -cost);
- ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (REFINE SUCCESS)");
- // END_OF_DETAIL_REFINE_LOG
- pkNewItem->AddToCharacter(this, TItemPos(INVENTORY, bCell));
- ITEM_MANAGER::instance().FlushDelayedSave(pkNewItem);
- sys_log(0, "Refine Success %d", cost);
- pkNewItem->AttrLog();
- //PointChange(POINT_GOLD, -cost);
- sys_log(0, "PayPee %d", cost);
- PayRefineFee(cost);
- #ifdef ENABLE_FEATURES_REFINE_SYSTEM
- CRefineManager::instance().Reset(this);
- #endif
- sys_log(0, "PayPee End %d", cost);
- }
- else
- {
- // DETAIL_REFINE_LOG
- sys_err("cannot create item %u", result_vnum);
- NotifyRefineFail(this, item, IsRefineThroughGuild() ? "GUILD" : "POWER");
- // END_OF_DETAIL_REFINE_LOG
- }
- }
- else
- {
- DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, item->GetVnum(), -cost);
- NotifyRefineFail(this, item, IsRefineThroughGuild() ? "GUILD" : "POWER");
- item->AttrLog();
- ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (REFINE FAIL)");
- //PointChange(POINT_GOLD, -cost);
- PayRefineFee(cost);
- #ifdef ENABLE_FEATURES_REFINE_SYSTEM
- CRefineManager::instance().Reset(this);
- #endif
- }
- return true;
- }
- enum enum_RefineScrolls
- {
- CHUKBOK_SCROLL = 0,
- HYUNIRON_CHN = 1,
- YONGSIN_SCROLL = 2,
- MUSIN_SCROLL = 3,
- YAGONG_SCROLL = 4,
- MEMO_SCROLL = 5,
- BDRAGON_SCROLL = 6,
- };
- bool CHARACTER::DoRefineWithScroll(LPITEM item)
- {
- if (!CanHandleItem(true))
- {
- ClearRefineMode();
- return false;
- }
- ClearRefineMode();
- if (quest::CQuestManager::instance().GetEventFlag("update_refine_time") != 0)
- {
- if (get_global_time() < quest::CQuestManager::instance().GetEventFlag("update_refine_time") + (60 * 5))
- {
- sys_log(0, "can't refine %d %s", GetPlayerID(), GetName());
- return false;
- }
- }
- const TRefineTable * prt = CRefineManager::instance().GetRefineRecipe(item->GetRefineSet());
- if (!prt)
- return false;
- LPITEM pkItemScroll;
- if (m_iRefineAdditionalCell < 0)
- return false;
- pkItemScroll = GetInventoryItem(m_iRefineAdditionalCell);
- if (!pkItemScroll)
- return false;
- if (!(pkItemScroll->GetType() == ITEM_USE && pkItemScroll->GetSubType() == USE_TUNING))
- return false;
- if (pkItemScroll->GetVnum() == item->GetVnum())
- return false;
- DWORD result_vnum = item->GetRefinedVnum();
- DWORD result_fail_vnum = item->GetRefineFromVnum();
- if (result_vnum == 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
- return false;
- }
- // MUSIN_SCROLL
- if (pkItemScroll->GetValue(0) == MUSIN_SCROLL)
- {
- if (item->GetRefineLevel() >= 4)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
- return false;
- }
- }
- // END_OF_MUSIC_SCROLL
- else if (pkItemScroll->GetValue(0) == MEMO_SCROLL)
- {
- if (item->GetRefineLevel() != pkItemScroll->GetValue(1))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
- return false;
- }
- }
- else if (pkItemScroll->GetValue(0) == BDRAGON_SCROLL)
- {
- if (item->GetType() != ITEM_METIN || item->GetRefineLevel() != 4)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
- return false;
- }
- }
- TItemTable * pProto = ITEM_MANAGER::instance().GetTable(item->GetRefinedVnum());
- if (!pProto)
- {
- sys_err("DoRefineWithScroll NOT GET ITEM PROTO %d", item->GetRefinedVnum());
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
- return false;
- }
- if (GetGold() < prt->cost)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai destui bani pentru upgrade."));
- return false;
- }
- for (int i = 0; i < prt->material_count; ++i)
- {
- if (CountSpecifyItem(prt->materials[i].vnum) < prt->materials[i].count)
- {
- if (test_server)
- {
- ChatPacket(CHAT_TYPE_INFO, "Find %d, count %d, require %d", prt->materials[i].vnum, CountSpecifyItem(prt->materials[i].vnum), prt->materials[i].count);
- }
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai materialele necesare."));
- return false;
- }
- }
- for (int i = 0; i < prt->material_count; ++i)
- RemoveSpecifyItem(prt->materials[i].vnum, prt->materials[i].count);
- int prob = number(1, 100);
- int success_prob = prt->prob;
- bool bDestroyWhenFail = false;
- const char* szRefineType = "SCROLL";
- if (pkItemScroll->GetValue(0) == HYUNIRON_CHN ||
- pkItemScroll->GetValue(0) == YONGSIN_SCROLL ||
- pkItemScroll->GetValue(0) == YAGONG_SCROLL)
- {
- const char hyuniron_prob[9] = { 100, 75, 65, 55, 45, 40, 35, 25, 20 };
- const char hyuniron_prob_euckr[9] = { 100, 75, 65, 55, 45, 40, 35, 30, 25 };
- const char yagong_prob[9] = { 100, 100, 90, 80, 70, 60, 50, 30, 20 };
- const char yagong_prob_euckr[9] = { 100, 100, 90, 80, 70, 60, 50, 40, 30 };
- if (pkItemScroll->GetValue(0) == YONGSIN_SCROLL)
- {
- success_prob = hyuniron_prob[MINMAX(0, item->GetRefineLevel(), 8)];
- }
- else if (pkItemScroll->GetValue(0) == YAGONG_SCROLL)
- {
- success_prob = yagong_prob[MINMAX(0, item->GetRefineLevel(), 8)];
- }
- else if (pkItemScroll->GetValue(0) == HYUNIRON_CHN) {} // @fixme121
- else
- {
- sys_err("REFINE : Unknown refine scroll item. Value0: %d", pkItemScroll->GetValue(0));
- }
- if (test_server)
- {
- ChatPacket(CHAT_TYPE_INFO, "[Only Test] Success_Prob %d, RefineLevel %d ", success_prob, item->GetRefineLevel());
- }
- if (pkItemScroll->GetValue(0) == HYUNIRON_CHN)
- bDestroyWhenFail = true;
- // DETAIL_REFINE_LOG
- if (pkItemScroll->GetValue(0) == HYUNIRON_CHN)
- {
- szRefineType = "HYUNIRON";
- }
- else if (pkItemScroll->GetValue(0) == YONGSIN_SCROLL)
- {
- szRefineType = "GOD_SCROLL";
- }
- else if (pkItemScroll->GetValue(0) == YAGONG_SCROLL)
- {
- szRefineType = "YAGONG_SCROLL";
- }
- // END_OF_DETAIL_REFINE_LOG
- }
- // DETAIL_REFINE_LOG
- if (pkItemScroll->GetValue(0) == MUSIN_SCROLL)
- {
- success_prob = 100;
- szRefineType = "MUSIN_SCROLL";
- }
- // END_OF_DETAIL_REFINE_LOG
- else if (pkItemScroll->GetValue(0) == MEMO_SCROLL)
- {
- success_prob = 100;
- szRefineType = "MEMO_SCROLL";
- }
- else if (pkItemScroll->GetValue(0) == BDRAGON_SCROLL)
- {
- success_prob = 80;
- szRefineType = "BDRAGON_SCROLL";
- }
- pkItemScroll->SetCount(pkItemScroll->GetCount() - 1);
- #ifdef ENABLE_FEATURES_REFINE_SYSTEM
- success_prob += CRefineManager::instance().Result(this);
- #endif
- if (prob <= success_prob)
- {
- LPITEM pkNewItem = ITEM_MANAGER::instance().CreateItem(result_vnum, 1, 0, false);
- if (pkNewItem)
- {
- ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
- LogManager::instance().ItemLog(this, pkNewItem, "REFINE SUCCESS", pkNewItem->GetName());
- BYTE bCell = item->GetCell();
- NotifyRefineSuccess(this, item, szRefineType);
- DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, item->GetVnum(), -prt->cost);
- ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (REFINE SUCCESS)");
- pkNewItem->AddToCharacter(this, TItemPos(INVENTORY, bCell));
- ITEM_MANAGER::instance().FlushDelayedSave(pkNewItem);
- pkNewItem->AttrLog();
- //PointChange(POINT_GOLD, -prt->cost);
- PayRefineFee(prt->cost);
- #ifdef ENABLE_FEATURES_REFINE_SYSTEM
- CRefineManager::instance().Reset(this);
- #endif
- }
- else
- {
- sys_err("cannot create item %u", result_vnum);
- NotifyRefineFail(this, item, szRefineType);
- }
- }
- else if (!bDestroyWhenFail && result_fail_vnum)
- {
- LPITEM pkNewItem = ITEM_MANAGER::instance().CreateItem(result_fail_vnum, 1, 0, false);
- if (pkNewItem)
- {
- ITEM_MANAGER::CopyAllAttrTo(item, pkNewItem);
- LogManager::instance().ItemLog(this, pkNewItem, "REFINE FAIL", pkNewItem->GetName());
- BYTE bCell = item->GetCell();
- DBManager::instance().SendMoneyLog(MONEY_LOG_REFINE, item->GetVnum(), -prt->cost);
- NotifyRefineFail(this, item, szRefineType, -1);
- ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (REFINE FAIL)");
- pkNewItem->AddToCharacter(this, TItemPos(INVENTORY, bCell));
- ITEM_MANAGER::instance().FlushDelayedSave(pkNewItem);
- pkNewItem->AttrLog();
- //PointChange(POINT_GOLD, -prt->cost);
- PayRefineFee(prt->cost);
- #ifdef ENABLE_FEATURES_REFINE_SYSTEM
- CRefineManager::instance().Reset(this);
- #endif
- }
- else
- {
- sys_err("cannot create item %u", result_fail_vnum);
- NotifyRefineFail(this, item, szRefineType);
- }
- }
- else
- {
- NotifyRefineFail(this, item, szRefineType);
- PayRefineFee(prt->cost);
- #ifdef ENABLE_FEATURES_REFINE_SYSTEM
- CRefineManager::instance().Reset(this);
- #endif
- }
- return true;
- }
- bool CHARACTER::RefineInformation(BYTE bCell, BYTE bType, int iAdditionalCell)
- {
- if (bCell > INVENTORY_MAX_NUM)
- return false;
- LPITEM item = GetInventoryItem(bCell);
- if (!item)
- return false;
- // REFINE_COST
- if (bType == REFINE_TYPE_MONEY_ONLY && !GetQuestFlag("deviltower_zone.can_refine"))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Recompensa pentru finalizarea Turnului Demonilor poate fi folosita pana la o singura data."));
- return false;
- }
- // END_OF_REFINE_COST
- TPacketGCRefineInformation p;
- p.header = HEADER_GC_REFINE_INFORMATION;
- p.pos = bCell;
- p.src_vnum = item->GetVnum();
- p.result_vnum = item->GetRefinedVnum();
- p.type = bType;
- if (p.result_vnum == 0)
- {
- sys_err("RefineInformation p.result_vnum == 0");
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
- return false;
- }
- if (item->GetType() == ITEM_USE && item->GetSubType() == USE_TUNING)
- {
- if (bType == 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poate fi inbunatatit."));
- return false;
- }
- else
- {
- LPITEM itemScroll = GetInventoryItem(iAdditionalCell);
- if (!itemScroll || item->GetVnum() == itemScroll->GetVnum())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asta."));
- return false;
- }
- }
- }
- CRefineManager & rm = CRefineManager::instance();
- const TRefineTable* prt = rm.GetRefineRecipe(item->GetRefineSet());
- if (!prt)
- {
- sys_err("RefineInformation NOT GET REFINE SET %d", item->GetRefineSet());
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poate fi inbunatatit."));
- return false;
- }
- // REFINE_COST
- //MAIN_QUEST_LV7
- if (GetQuestFlag("main_quest_lv7.refine_chance") > 0)
- {
- if (!item->CheckItemUseLevel(20) || item->GetType() != ITEM_WEAPON)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Upgrade gratuit de la nivel 20"));
- return false;
- }
- p.cost = 0;
- }
- else
- p.cost = ComputeRefineFee(prt->cost);
- //END_MAIN_QUEST_LV7
- p.prob = prt->prob;
- if (bType == REFINE_TYPE_MONEY_ONLY)
- {
- p.material_count = 0;
- memset(p.materials, 0, sizeof(p.materials));
- }
- else
- {
- p.material_count = prt->material_count;
- thecore_memcpy(&p.materials, prt->materials, sizeof(prt->materials));
- }
- // END_OF_REFINE_COST
- GetDesc()->Packet(&p, sizeof(TPacketGCRefineInformation));
- SetRefineMode(iAdditionalCell);
- return true;
- }
- bool CHARACTER::RefineItem(LPITEM pkItem, LPITEM pkTarget)
- {
- if (!CanHandleItem())
- return false;
- if (pkItem->GetSubType() == USE_TUNING)
- {
- // MUSIN_SCROLL
- if (pkItem->GetValue(0) == MUSIN_SCROLL)
- RefineInformation(pkTarget->GetCell(), REFINE_TYPE_MUSIN, pkItem->GetCell());
- // END_OF_MUSIN_SCROLL
- else if (pkItem->GetValue(0) == HYUNIRON_CHN)
- RefineInformation(pkTarget->GetCell(), REFINE_TYPE_HYUNIRON, pkItem->GetCell());
- else if (pkItem->GetValue(0) == BDRAGON_SCROLL)
- {
- if (pkTarget->GetRefineSet() != 702) return false;
- RefineInformation(pkTarget->GetCell(), REFINE_TYPE_BDRAGON, pkItem->GetCell());
- }
- else
- {
- if (pkTarget->GetRefineSet() == 501) return false;
- RefineInformation(pkTarget->GetCell(), REFINE_TYPE_SCROLL, pkItem->GetCell());
- }
- }
- else if (pkItem->GetSubType() == USE_DETACHMENT && IS_SET(pkTarget->GetFlag(), ITEM_FLAG_REFINEABLE))
- {
- LogManager::instance().ItemLog(this, pkTarget, "USE_DETACHMENT", pkTarget->GetName());
- bool bHasMetinStone = false;
- for (int i = 0; i < ITEM_SOCKET_MAX_NUM; i++)
- {
- long socket = pkTarget->GetSocket(i);
- if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
- {
- bHasMetinStone = true;
- break;
- }
- }
- if (bHasMetinStone)
- {
- for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
- {
- long socket = pkTarget->GetSocket(i);
- if (socket > 2 && socket != ITEM_BROKEN_METIN_VNUM)
- {
- AutoGiveItem(socket);
- pkTarget->SetSocket(i, ITEM_BROKEN_METIN_VNUM);
- }
- }
- pkItem->SetCount(pkItem->GetCount() - 1);
- return true;
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu exista nici-o piatra."));
- return false;
- }
- }
- return false;
- }
- EVENTFUNC(kill_campfire_event)
- {
- char_event_info* info = dynamic_cast<char_event_info*>( event->info );
- if ( info == NULL )
- {
- sys_err( "kill_campfire_event> <Factor> Null pointer" );
- return 0;
- }
- LPCHARACTER ch = info->ch;
- if (ch == NULL)
- { // <Factor>
- return 0;
- }
- ch->m_pkMiningEvent = NULL;
- M2_DESTROY_CHARACTER(ch);
- return 0;
- }
- bool CHARACTER::GiveRecallItem(LPITEM item)
- {
- int idx = GetMapIndex();
- int iEmpireByMapIndex = -1;
- if (idx < 20)
- iEmpireByMapIndex = 1;
- else if (idx < 40)
- iEmpireByMapIndex = 2;
- else if (idx < 60)
- iEmpireByMapIndex = 3;
- else if (idx < 10000)
- iEmpireByMapIndex = 0;
- switch (idx)
- {
- case 66:
- case 216:
- iEmpireByMapIndex = -1;
- break;
- }
- if (iEmpireByMapIndex && GetEmpire() != iEmpireByMapIndex)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu-mi amintesc aceasta locatie"));
- return false;
- }
- int pos;
- if (item->GetCount() == 1)
- {
- item->SetSocket(0, GetX());
- item->SetSocket(1, GetY());
- }
- else if ((pos = GetEmptyInventory(item->GetSize())) != -1)
- {
- LPITEM item2 = ITEM_MANAGER::instance().CreateItem(item->GetVnum(), 1);
- if (NULL != item2)
- {
- item2->SetSocket(0, GetX());
- item2->SetSocket(1, GetY());
- item2->AddToCharacter(this, TItemPos(INVENTORY, pos));
- item->SetCount(item->GetCount() - 1);
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
- return false;
- }
- return true;
- }
- void CHARACTER::ProcessRecallItem(LPITEM item)
- {
- int idx;
- if ((idx = SECTREE_MANAGER::instance().GetMapIndex(item->GetSocket(0), item->GetSocket(1))) == 0)
- return;
- int iEmpireByMapIndex = -1;
- if (idx < 20)
- iEmpireByMapIndex = 1;
- else if (idx < 40)
- iEmpireByMapIndex = 2;
- else if (idx < 60)
- iEmpireByMapIndex = 3;
- else if (idx < 10000)
- iEmpireByMapIndex = 0;
- switch (idx)
- {
- case 66:
- case 216:
- iEmpireByMapIndex = -1;
- break;
- case 301:
- case 302:
- case 303:
- case 304:
- if( GetLevel() < 90 )
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nivelul tau este prea mic."));
- return;
- }
- else
- break;
- }
- if (iEmpireByMapIndex && GetEmpire() != iEmpireByMapIndex)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
- item->SetSocket(0, 0);
- item->SetSocket(1, 0);
- }
- else
- {
- sys_log(1, "Recall: %s %d %d -> %d %d", GetName(), GetX(), GetY(), item->GetSocket(0), item->GetSocket(1));
- WarpSet(item->GetSocket(0), item->GetSocket(1));
- item->SetCount(item->GetCount() - 1);
- }
- }
- void CHARACTER::__OpenPrivateShop()
- {
- unsigned bodyPart = GetPart(PART_MAIN);
- switch (bodyPart)
- {
- case 0:
- case 1:
- case 2:
- ChatPacket(CHAT_TYPE_COMMAND, "OpenPrivateShop");
- break;
- default:
- ChatPacket(CHAT_TYPE_COMMAND, "OpenPrivateShop");
- break;
- }
- }
- // MYSHOP_PRICE_LIST
- void CHARACTER::SendMyShopPriceListCmd(DWORD dwItemVnum, long long dwItemPrice)
- {
- char szLine[256];
- snprintf(szLine, sizeof(szLine), "MyShopPriceList %u %lld", dwItemVnum, dwItemPrice);
- ChatPacket(CHAT_TYPE_COMMAND, szLine);
- sys_log(0, szLine);
- }
- void CHARACTER::UseSilkBotaryReal(const TPacketMyshopPricelistHeader* p)
- {
- const TItemPriceInfo* pInfo = (const TItemPriceInfo*)(p + 1);
- if (!p->byCount)
- SendMyShopPriceListCmd(1, 0);
- else {
- for (int idx = 0; idx < p->byCount; idx++)
- SendMyShopPriceListCmd(pInfo[ idx ].dwVnum, pInfo[ idx ].dwPrice);
- }
- __OpenPrivateShop();
- }
- void CHARACTER::UseSilkBotary(void)
- {
- if (m_bNoOpenedShop) {
- DWORD dwPlayerID = GetPlayerID();
- db_clientdesc->DBPacket(HEADER_GD_MYSHOP_PRICELIST_REQ, GetDesc()->GetHandle(), &dwPlayerID, sizeof(DWORD));
- m_bNoOpenedShop = false;
- } else {
- __OpenPrivateShop();
- }
- }
- // END_OF_MYSHOP_PRICE_LIST
- int CalculateConsume(LPCHARACTER ch)
- {
- static const int WARP_NEED_LIFE_PERCENT = 30;
- static const int WARP_MIN_LIFE_PERCENT = 10;
- // CONSUME_LIFE_WHEN_USE_WARP_ITEM
- int consumeLife = 0;
- {
- // CheckNeedLifeForWarp
- const int curLife = ch->GetHP();
- const int needPercent = WARP_NEED_LIFE_PERCENT;
- const int needLife = ch->GetMaxHP() * needPercent / 100;
- if (curLife < needLife)
- {
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai destula viata pentru a folosi un pergament."));
- return -1;
- }
- consumeLife = needLife;
- const int minPercent = WARP_MIN_LIFE_PERCENT;
- const int minLife = ch->GetMaxHP() * minPercent / 100;
- if (curLife - needLife < minLife)
- consumeLife = curLife - minLife;
- if (consumeLife < 0)
- consumeLife = 0;
- }
- // END_OF_CONSUME_LIFE_WHEN_USE_WARP_ITEM
- return consumeLife;
- }
- int CalculateConsumeSP(LPCHARACTER lpChar)
- {
- static const int NEED_WARP_SP_PERCENT = 30;
- const int curSP = lpChar->GetSP();
- const int needSP = lpChar->GetMaxSP() * NEED_WARP_SP_PERCENT / 100;
- if (curSP < needSP)
- {
- lpChar->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai destule puncte SP."));
- return -1;
- }
- return needSP;
- }
- #ifdef ENABLE_YMIR_AFFECT_FIX
- bool CHARACTER::CheckTimeUsed(LPITEM item)
- {
- switch (item->GetVnum())
- {
- /****************
- * Type = 27 -> ITEM_BLEND (Delete the other case you do not want for check)
- */
- case 50821: case 50822: case 50823: case 50824: case 50825: case 50826:
- case 50813: case 50814: case 50815: case 50816: case 50817: case 50818:
- case 50819: case 50820: case 27866: case 27868: case 27870: case 27873:
- case 39026: case 50093: case 50094: case 50123: case 50801: case 50802:
- case 39010: case 39017: case 39018: case 39019: case 39020: case 39024:
- case 39025: case 39031: case 71014: case 71015: case 71016: case 71017:
- case 71027: case 71028: case 71029: case 71030: case 71034: case 71044:
- case 71045: case 71101: case 71102: case 71153: case 71154: case 71155:
- case 71156: case 72025: case 72026: case 72027: case 72031: case 72032:
- case 72033: case 72034: case 72035: case 72036: case 72037: case 76018:
- case 72038: case 72039: case 72040: case 72041: case 72042: case 72046:
- case 72047: case 72048: case 72312: case 72313: case 72501: case 72502:
- int pGetTime[] = {5}; // Set timer for how you need a long after you login for can use item
- int pGetFlag = GetQuestFlag("item.last_time"); // Get questflag where him set from input_login.cpp (Not change)
- const char* pGetMessage[] = {"|cFFd0ffcc|H|h Nu poti folosii |cFFc9ff00|H|h[%s] |cFFd0ffcc|H|h numai dupa trecerea a|cFFec03e2|H|h[%u] |cFFd0ffcc|H|h de secunde de la loginul initiat!"}; // Get message when you use time so fast
- if (pGetFlag) // Initializate questflag on item
- {
- if (get_global_time() < pGetFlag + pGetTime[0]) // Initializate to get a + second for questflag
- {
- ChatPacket(CHAT_TYPE_INFO, pGetMessage[0], item->GetName(), pGetTime[0]); // Get message
- return false; // Returns false if you use the item quicker than those seconds
- }
- }
- break;
- }
- return true;
- }
- #endif
- #ifdef ENABLE_NEW_AFFECT_POTION
- void CHARACTER::SetAffectPotion(LPITEM item)
- {
- if (!item)
- return;
- int iPotionAffects[] = {AFFECT_POTION_1, AFFECT_POTION_2, AFFECT_POTION_3, AFFECT_POTION_4, AFFECT_POTION_5, AFFECT_POTION_6};
- int iPotionVnums[] = {50821, 50822, 50823, 50824, 50825, 50826};
- for (int i = 0; i < _countof(iPotionVnums); i++)
- {
- if (item->GetVnum() == iPotionVnums[i])
- #ifdef ENABLE_DEWS_PLUS
- AddAffect(iPotionAffects[i], APPLY_NONE, 0, AFF_NONE, INFINITE_AFFECT_DURATION, 0, false, false);
- #else
- AddAffect(iPotionAffects[i], APPLY_NONE, 0, AFF_NONE, item->GetSocket(2), 0, false, false);
- #endif
- }
- }
- void CHARACTER::RemoveAffectPotion(LPITEM item)
- {
- if (!item)
- return;
- int iPotionAffects[] = {AFFECT_POTION_1, AFFECT_POTION_2, AFFECT_POTION_3, AFFECT_POTION_4, AFFECT_POTION_5, AFFECT_POTION_6};
- int iPotionVnums[] = {50821, 50822, 50823, 50824, 50825, 50826};
- for (int i = 0; i < _countof(iPotionVnums); i++)
- {
- if (item->GetVnum() == iPotionVnums[i])
- RemoveAffect(iPotionAffects[i]);
- }
- }
- #endif
- bool CHARACTER::UseItemEx(LPITEM item, TItemPos DestCell)
- {
- int iLimitRealtimeStartFirstUseFlagIndex = -1;
- //int iLimitTimerBasedOnWearFlagIndex = -1;
- WORD wDestCell = DestCell.cell;
- BYTE bDestInven = DestCell.window_type;
- for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
- {
- long limitValue = item->GetProto()->aLimits[i].lValue;
- switch (item->GetProto()->aLimits[i].bType)
- {
- case LIMIT_LEVEL:
- if (GetLevel() < limitValue)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nivelul tau este prea mic pentru a purta acest obiect"));
- return false;
- }
- break;
- case LIMIT_REAL_TIME_START_FIRST_USE:
- iLimitRealtimeStartFirstUseFlagIndex = i;
- break;
- case LIMIT_TIMER_BASED_ON_WEAR:
- //iLimitTimerBasedOnWearFlagIndex = i;
- break;
- }
- }
- if (test_server)
- {
- //sys_log(0, "USE_ITEM %s, Inven %d, Cell %d, ItemType %d, SubType %d", item->GetName(), bDestInven, wDestCell, item->GetType(), item->GetSubType());
- }
- if ( CArenaManager::instance().IsLimitedItem( GetMapIndex(), item->GetVnum() ) == true )
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- return false;
- }
- // @fixme141 BEGIN
- if (TItemPos(item->GetWindow(), item->GetCell()).IsBeltInventoryPosition())
- {
- LPITEM beltItem = GetWear(WEAR_BELT);
- if (NULL == beltItem)
- {
- ChatPacket(CHAT_TYPE_INFO, "<Belt> You can't use this item if you have no equipped belt.");
- return false;
- }
- if (false == CBeltInventoryHelper::IsAvailableCell(item->GetCell() - BELT_INVENTORY_SLOT_START, beltItem->GetValue(0)))
- {
- ChatPacket(CHAT_TYPE_INFO, "<Belt> You can't use this item if you don't upgrade your belt.");
- return false;
- }
- }
- // @fixme141 END
- if (item->GetVnum() >= 80003 && item->GetVnum() <= 80008)
- {
- int VnumLingouri[] = {80003, 80004, 80005, 80006, 80007, 80008};
- long SumaLingouri[] = {1000000, 2000000, 5000000, 10000000, 15000000, 20000000};
- long long MaxiLingouri[] = {90000000000LL, 90000000000LL, 90000000000LL, 90000000000LL, 90000000000LL, 90000000000LL};
- for (int i = 0; i < _countof(VnumLingouri); i++)
- {
- if (item->GetVnum() == VnumLingouri[i])
- {
- if (IsOpenSafebox() || GetExchange() || GetMyShop() || IsCubeOpen())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti sa utilizezi un lingou cat timp negociezi."));
- return false;
- }
- else
- {
- if (item->GetVnum() == VnumLingouri[i] && GetGold()>= MaxiLingouri[i])
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul daca ai peste 90kkk (90-Mld.) !"));
- return false;
- }
- if (item->GetVnum() == VnumLingouri[i+1] && GetGold()>= MaxiLingouri[i+1])
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul daca ai peste 90kkk (90-Mld.) !"));
- return false;
- }
- if (item->GetVnum() == VnumLingouri[i+2] && GetGold()>= MaxiLingouri[i+2])
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul daca ai peste 90kkk (90-Mld.) !"));
- return false;
- }
- if (item->GetVnum() == VnumLingouri[i+3] && GetGold()>= MaxiLingouri[i+3])
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul daca ai peste 90kkk (90-Mld.) !"));
- return false;
- }
- if (item->GetVnum() == VnumLingouri[i+4] && GetGold()>= MaxiLingouri[i+4])
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul daca ai peste 90kkk (90-Mld.) !"));
- return false;
- }
- if (item->GetVnum() == VnumLingouri[i+5] && GetGold()>= MaxiLingouri[i+5])
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide lingoul daca ai peste 90kkk (90-Mld.) !"));
- return false;
- }
- else
- {
- item->SetCount(item->GetCount() - 1);
- PointChange(POINT_GOLD, SumaLingouri[i], true);
- return true;
- }
- }
- }
- }
- return false;
- }
- #ifdef NEW_PET_SYSTEM
- if (item->GetVnum() == 55001)
- {
- LPITEM item2;
- if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
- return false;
- if (item2->IsExchanging())
- return false;
- if (item2->GetVnum() >= 55718 || item2->GetVnum() < 55701)
- return false;
- char szQuery1[1024];
- snprintf(szQuery1, sizeof(szQuery1), "SELECT duration FROM new_petsystem WHERE id = %lu LIMIT 1", item2->GetID());
- std::unique_ptr<SQLMsg> pmsg2(DBManager::instance().DirectQuery(szQuery1));
- if (pmsg2->Get()->uiNumRows > 0)
- {
- MYSQL_ROW row = mysql_fetch_row(pmsg2->Get()->pSQLResult);
- if (atoi(row[0]) > 0)
- {
- if (GetNewPetSystem()->IsActivePet())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have to unsummon your pet first."));
- return false;
- }
- DBManager::instance().DirectQuery("UPDATE new_petsystem SET duration =(tduration) WHERE id = %d", item2->GetID());
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Your Pet's life is now full."));
- }
- else
- {
- DBManager::instance().DirectQuery("UPDATE new_petsystem SET duration =(tduration/2) WHERE id = %d", item2->GetID());
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Your Pet's life is now restored."));
- }
- item->SetCount(item->GetCount() - 1);
- return true;
- }
- else
- return false;
- }
- if (item->GetVnum() >= 55701 && item->GetVnum() <= 55718)
- {
- LPITEM item2;
- if (item2 = GetItem(DestCell))
- {
- if (item2->GetVnum() == 55002)
- {
- if(item2->GetAttributeValue(0) > 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Cutia are deja un animalut inauntru."));
- }
- else if (item->GetAttributeValue(3) == 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Scoate animalutul din ou mai intai!"));
- return false;
- }
- else
- {
- if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
- return false;
- if (item2->IsExchanging())
- return false;
- if (GetNewPetSystem()->IsActivePet())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have to unsummon your pet first."));
- return false;
- }
- for (int b = 0; b < 3; b++)
- {
- item2->SetForceAttribute(b, 1, item->GetAttributeValue(b));
- }
- item2->SetForceAttribute(3, 1, item->GetAttributeValue(3));
- item2->SetForceAttribute(4, 1, item->GetAttributeValue(4));
- //Pet Yas Bugu Fixi//
- //item2->SetForceAttribute(5, 1, item->GetAttributeValue(5));
- //Pet Yas Bugu Fixi//
- DWORD vnum1 = item->GetVnum()-55700;
- item2->SetSocket(2, vnum1);
- item2->SetSocket(1, item->GetSocket(1));
- //ChatPacket(CHAT_TYPE_INFO, "Pet %d %d %d //// %d %d %d",item->GetAttributeValue(0),item->GetAttributeValue(1),item->GetAttributeValue(2),item2->GetAttributeValue(0),item2->GetAttributeValue(1),item2->GetAttributeValue(2));
- DBManager::instance().DirectQuery("UPDATE new_petsystem SET id =%d WHERE id = %d", item2->GetID(), item->GetID());
- ITEM_MANAGER::instance().RemoveItem(item);
- return true;
- }
- }
- }
- }
- if (item->GetVnum() == 55009)
- {
- int number1461 = number(55010,55027);
- AutoGiveItem(number1461);
- item->SetCount(item->GetCount() - 1);
- }
- if (-1 != iLimitRealtimeStartFirstUseFlagIndex)
- {
- if (0 == item->GetSocket(1))
- {
- long duration = (0 != item->GetSocket(0)) ? item->GetSocket(0) : item->GetProto()->aLimits[iLimitRealtimeStartFirstUseFlagIndex].lValue;
- if (0 == duration)
- duration = 60 * 60 * 24 * 7;
- item->SetSocket(0, time(0) + duration);
- item->StartRealTimeExpireEvent();
- }
- if (false == item->IsEquipped())
- item->SetSocket(1, item->GetSocket(1) + 1);
- }
- if (item->GetVnum() == 55002 && item->GetAttributeValue(0) > 0)
- {
- int pos = GetEmptyInventory(item->GetSize());
- if(pos == -1)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai destul spatiu in inventar!"));
- return false;
- }
- if (GetLevel() < item->GetSocket(1))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nivelul animalutului mai mare decat nivelul tau"));
- return false;
- }
- if (item->IsExchanging())
- return false;
- DWORD vnum2 = 55700+item->GetSocket(2);
- LPITEM item2 = AutoGiveItem(vnum2, 1);
- for (int b = 0; b < 3; b++)
- {
- item2->SetForceAttribute(b, 1, item->GetAttributeValue(b));
- }
- item2->SetForceAttribute(3, 1, item->GetAttributeValue(3));
- item2->SetForceAttribute(4, 1, item->GetAttributeValue(4));
- //Pet Yas Bugu Fixi//
- //item2->SetForceAttribute(5, 1, item->GetAttributeValue(5));
- //Pet Yas Bugu Fixi//
- item2->SetSocket(1,item->GetSocket(1));
- //ChatPacket(CHAT_TYPE_INFO, "Pet1 %d %d %d",item->GetAttributeValue(0),item->GetAttributeValue(1),item->GetAttributeValue(2));
- DBManager::instance().DirectQuery("UPDATE new_petsystem SET id =%d WHERE id = %d", item2->GetID(), item->GetID());
- ITEM_MANAGER::instance().RemoveItem(item);
- return true;
- }
- #endif
- #ifdef __BATTLE_PASS__
- if (!v_counts.empty())
- {
- for (int i=0; i<missions_bp.size(); ++i)
- {
- if (missions_bp[i].type == 1 && item->GetVnum() == missions_bp[i].vnum)
- {
- DoMission(i, 1);
- }
- }
- }
- #endif
- switch (item->GetType())
- {
- case ITEM_HAIR:
- return ItemProcess_Hair(item, wDestCell);
- case ITEM_POLYMORPH:
- return ItemProcess_Polymorph(item);
- case ITEM_QUEST:
- if (GetArena() != NULL || IsObserverMode() == true)
- {
- if (item->GetVnum() == 50051 || item->GetVnum() == 50052 || item->GetVnum() == 50053)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- return false;
- }
- }
- if (!IS_SET(item->GetFlag(), ITEM_FLAG_QUEST_USE | ITEM_FLAG_QUEST_USE_MULTIPLE))
- {
- if (item->GetSIGVnum() == 0)
- {
- quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
- }
- else
- {
- quest::CQuestManager::instance().SIGUse(GetPlayerID(), item->GetSIGVnum(), item, false);
- }
- }
- break;
- case ITEM_CAMPFIRE:
- {
- float fx, fy;
- GetDeltaByDegree(GetRotation(), 100.0f, &fx, &fy);
- LPSECTREE tree = SECTREE_MANAGER::instance().Get(GetMapIndex(), (long)(GetX()+fx), (long)(GetY()+fy));
- if (!tree)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("No fire."));
- return false;
- }
- if (tree->IsAttr((long)(GetX()+fx), (long)(GetY()+fy), ATTR_WATER))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("No fire."));
- return false;
- }
- LPCHARACTER campfire = CHARACTER_MANAGER::instance().SpawnMob(fishing::CAMPFIRE_MOB, GetMapIndex(), (long)(GetX()+fx), (long)(GetY()+fy), 0, false, number(0, 359));
- char_event_info* info = AllocEventInfo<char_event_info>();
- info->ch = campfire;
- campfire->m_pkMiningEvent = event_create(kill_campfire_event, info, PASSES_PER_SEC(40));
- item->SetCount(item->GetCount() - 1);
- }
- break;
- case ITEM_UNIQUE:
- {
- switch (item->GetSubType())
- {
- case USE_ABILITY_UP:
- {
- switch (item->GetValue(0))
- {
- case APPLY_MOV_SPEED:
- AddAffect(AFFECT_UNIQUE_ABILITY, POINT_MOV_SPEED, item->GetValue(2), AFF_MOV_SPEED_POTION, item->GetValue(1), 0, true, true);
- EffectPacket(SE_DXUP_PURPLE); //purple potion
- break;
- case APPLY_ATT_SPEED:
- AddAffect(AFFECT_UNIQUE_ABILITY, POINT_ATT_SPEED, item->GetValue(2), AFF_ATT_SPEED_POTION, item->GetValue(1), 0, true, true);
- EffectPacket(SE_SPEEDUP_GREEN); //green potion
- break;
- case APPLY_STR:
- AddAffect(AFFECT_UNIQUE_ABILITY, POINT_ST, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
- break;
- case APPLY_DEX:
- AddAffect(AFFECT_UNIQUE_ABILITY, POINT_DX, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
- break;
- case APPLY_CON:
- AddAffect(AFFECT_UNIQUE_ABILITY, POINT_HT, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
- break;
- case APPLY_INT:
- AddAffect(AFFECT_UNIQUE_ABILITY, POINT_IQ, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
- break;
- case APPLY_CAST_SPEED:
- AddAffect(AFFECT_UNIQUE_ABILITY, POINT_CASTING_SPEED, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
- break;
- case APPLY_RESIST_MAGIC:
- AddAffect(AFFECT_UNIQUE_ABILITY, POINT_RESIST_MAGIC, item->GetValue(2), 0, item->GetValue(1), 0, true, true);
- break;
- case APPLY_ATT_GRADE_BONUS:
- AddAffect(AFFECT_UNIQUE_ABILITY, POINT_ATT_GRADE_BONUS,
- item->GetValue(2), 0, item->GetValue(1), 0, true, true);
- break;
- case APPLY_DEF_GRADE_BONUS:
- AddAffect(AFFECT_UNIQUE_ABILITY, POINT_DEF_GRADE_BONUS,
- item->GetValue(2), 0, item->GetValue(1), 0, true, true);
- break;
- }
- }
- if (GetDungeon())
- GetDungeon()->UsePotion(this);
- if (GetWarMap())
- GetWarMap()->UsePotion(this, item);
- item->SetCount(item->GetCount() - 1);
- break;
- default:
- {
- if (item->GetSubType() == USE_SPECIAL)
- {
- sys_log(0, "ITEM_UNIQUE: USE_SPECIAL %u", item->GetVnum());
- switch (item->GetVnum())
- {
- case 71049:
- if (LC_IsYMIR() == true || LC_IsKorea() == true)
- {
- if (IS_BOTARYABLE_ZONE(GetMapIndex()) == true)
- {
- UseSilkBotary();
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("SHOP_OX_ERROR"));
- }
- }
- else
- {
- UseSilkBotary();
- }
- break;
- }
- }
- else
- {
- if (!item->IsEquipped())
- EquipItem(item);
- else
- UnequipItem(item);
- }
- }
- break;
- }
- }
- break;
- case ITEM_COSTUME:
- case ITEM_WEAPON:
- case ITEM_ARMOR:
- case ITEM_ROD:
- case ITEM_RING: // ½Å±Ô ¹ÝÁö ¾ÆÀÌÅÛ
- case ITEM_BELT: // ½Å±Ô º§Æ® ¾ÆÀÌÅÛ
- #ifdef ENABLE_PET_SLOT
- case ITEM_NORMAL_PET:
- #endif
- // MINING
- case ITEM_PICK:
- // END_OF_MINING
- if (!item->IsEquipped())
- EquipItem(item);
- else
- UnequipItem(item);
- break;
- case ITEM_DS:
- {
- if (!item->IsEquipped())
- return false;
- return DSManager::instance().PullOut(this, NPOS, item);
- break;
- }
- case ITEM_SPECIAL_DS:
- if (!item->IsEquipped())
- EquipItem(item);
- else
- UnequipItem(item);
- break;
- case ITEM_FISH:
- {
- if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- return false;
- }
- if (item->GetSubType() == FISH_ALIVE)
- fishing::UseFish(this, item);
- }
- break;
- case ITEM_TREASURE_BOX:
- {
- return false;
- //ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("¿¼è·Î Àá°Ü ÀÖ¾î¼ ¿¸®Áö ¾Ê´Â°Í °°´Ù. ¿¼è¸¦ ±¸Çغ¸ÀÚ."));
- }
- break;
- case ITEM_TREASURE_KEY:
- {
- LPITEM item2;
- if (!GetItem(DestCell) || !(item2 = GetItem(DestCell)))
- return false;
- if (item2->IsExchanging() || item2->IsEquipped()) // @fixme114
- return false;
- if (item2->GetType() != ITEM_TREASURE_BOX)
- {
- ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("No_Key."));
- return false;
- }
- if (item->GetValue(0) == item2->GetValue(0))
- {
- DWORD dwBoxVnum = item2->GetVnum();
- std::vector <DWORD> dwVnums;
- std::vector <DWORD> dwCounts;
- std::vector <LPITEM> item_gets(0);
- int count = 0;
- if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
- {
- ITEM_MANAGER::instance().RemoveItem(item);
- ITEM_MANAGER::instance().RemoveItem(item2);
- for (int i = 0; i < count; i++){
- switch (dwVnums[i])
- {
- case CSpecialItemGroup::GOLD:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai primit nimic."), dwCounts[i]);
- break;
- case CSpecialItemGroup::EXP:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ºÎÅÍ ½ÅºñÇÑ ºûÀÌ ³ª¿É´Ï´Ù."));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dÀÇ °æÇèÄ¡¸¦ ȹµæÇß½À´Ï´Ù."), dwCounts[i]);
- break;
- case CSpecialItemGroup::MOB:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ¸ó½ºÅͰ¡ ³ªÅ¸³µ½À´Ï´Ù!"));
- break;
- case CSpecialItemGroup::SLOW:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ³ª¿Â »¡°£ ¿¬±â¸¦ µéÀ̸¶½ÃÀÚ ¿òÁ÷ÀÌ´Â ¼Óµµ°¡ ´À·ÁÁ³½À´Ï´Ù!"));
- break;
- case CSpecialItemGroup::DRAIN_HP:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ°¡ °©ÀÚ±â Æø¹ßÇÏ¿´½À´Ï´Ù! »ý¸í·ÂÀÌ °¨¼ÒÇß½À´Ï´Ù."));
- break;
- case CSpecialItemGroup::POISON:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ³ª¿Â ³ì»ö ¿¬±â¸¦ µéÀ̸¶½ÃÀÚ µ¶ÀÌ ¿Â¸öÀ¸·Î ÆÛÁý´Ï´Ù!"));
- break;
- case CSpecialItemGroup::MOB_GROUP:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ¸ó½ºÅͰ¡ ³ªÅ¸³µ½À´Ï´Ù!"));
- break;
- default:
- if (item_gets[i])
- {
- if (dwCounts[i] > 1)
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s - %d x."), item_gets[i]->GetName(), dwCounts[i]);
- else
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s."), item_gets[i]->GetName());
- }
- }
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("No_Key."));
- return false;
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("No_Key."));
- return false;
- }
- }
- break;
- case ITEM_GIFTBOX:
- {
- DWORD dwBoxVnum = item->GetVnum();
- std::vector <DWORD> dwVnums;
- std::vector <DWORD> dwCounts;
- std::vector <LPITEM> item_gets(NULL);
- int count = 0;
- if (dwBoxVnum == 50033 && LC_IsYMIR())
- {
- if (GetLevel() < 15)
- {
- ChatPacket(CHAT_TYPE_INFO, "Nu poate fi utilizat sub nivelul 15.");
- return false;
- }
- }
- if( (dwBoxVnum > 51500 && dwBoxVnum < 52000) || (dwBoxVnum >= 50255 && dwBoxVnum <= 50260) ) // ¿ëÈ¥¿ø¼®µé
- {
- if( !(this->DragonSoul_IsQualified()) )
- {
- ChatPacket(CHAT_TYPE_INFO,LC_TEXT("Finish_Dragon_Soul."));
- return false;
- }
- }
- if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
- {
- item->SetCount(item->GetCount()-1);
- for (int i = 0; i < count; i++){
- switch (dwVnums[i])
- {
- case CSpecialItemGroup::GOLD:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai primit nimic."), dwCounts[i]);
- break;
- case CSpecialItemGroup::EXP:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ºÎÅÍ ½ÅºñÇÑ ºûÀÌ ³ª¿É´Ï´Ù."));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dÀÇ °æÇèÄ¡¸¦ ȹµæÇß½À´Ï´Ù."), dwCounts[i]);
- break;
- case CSpecialItemGroup::MOB:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ¸ó½ºÅͰ¡ ³ªÅ¸³µ½À´Ï´Ù!"));
- break;
- case CSpecialItemGroup::SLOW:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ³ª¿Â »¡°£ ¿¬±â¸¦ µéÀ̸¶½ÃÀÚ ¿òÁ÷ÀÌ´Â ¼Óµµ°¡ ´À·ÁÁ³½À´Ï´Ù!"));
- break;
- case CSpecialItemGroup::DRAIN_HP:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ°¡ °©ÀÚ±â Æø¹ßÇÏ¿´½À´Ï´Ù! »ý¸í·ÂÀÌ °¨¼ÒÇß½À´Ï´Ù."));
- break;
- case CSpecialItemGroup::POISON:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ³ª¿Â ³ì»ö ¿¬±â¸¦ µéÀ̸¶½ÃÀÚ µ¶ÀÌ ¿Â¸öÀ¸·Î ÆÛÁý´Ï´Ù!"));
- break;
- case CSpecialItemGroup::MOB_GROUP:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ¸ó½ºÅͰ¡ ³ªÅ¸³µ½À´Ï´Ù!"));
- break;
- default:
- if (item_gets[i])
- {
- if (dwCounts[i] > 1)
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s - %d x."), item_gets[i]->GetName(), dwCounts[i]);
- else
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s."), item_gets[i]->GetName());
- }
- }
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("Nu am putut obtine nimic."));
- return false;
- }
- }
- break;
- case ITEM_SKILLFORGET:
- {
- if (!item->GetSocket(0))
- {
- item->SetCount(item->GetCount() - 1);
- return false;
- }
- DWORD dwVnum = item->GetSocket(0);
- if (SkillLevelDown(dwVnum))
- {
- item->SetCount(item->GetCount() - 1);
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ati reusit sa va reduceti nivelul de calificare"));
- }
- else
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu va puteti reduce nivelul de calificare."));
- }
- break;
- case ITEM_SKILLBOOK:
- {
- if (IsPolymorphed())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
- return false;
- }
- DWORD dwVnum = 0;
- if (item->GetVnum() == 50300)
- {
- dwVnum = item->GetSocket(0);
- }
- else
- {
- dwVnum = item->GetValue(0);
- }
- if (0 == dwVnum)
- {
- item->SetCount(item->GetCount() - 1);
- return false;
- }
- if (true == LearnSkillByBook(dwVnum))
- {
- #ifdef LEARN_BOOK_FIX
- item->SetCount(item->GetCount() - 1);
- #endif
- int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
- if (distribution_test_server)
- iReadDelay /= 3;
- if (LC_IsKorea())
- iReadDelay = 86400;
- SetSkillNextReadTime(dwVnum, get_global_time() + iReadDelay);
- }
- }
- break;
- case ITEM_USE:
- {
- switch (item->GetVnum())
- {
- case 40496:
- {
- if (GetLevel() > 4 && GetLevel() < 71)
- {
- {
- if (GetLevel() >= 5 && GetLevel() <=20)
- {
- const static DWORD cufar_armuri[12] = { 11207, 11217, 11227, 11407, 11417, 11427, 11607, 11617, 11627, 11807, 11817, 11827 };
- DWORD dwVnum = cufar_armuri[number(0, 11)];
- AutoGiveItem(dwVnum);
- }
- if (GetLevel() >= 21 && GetLevel() <=45)
- {
- const static DWORD cufar_armuri[12] = { 11237, 11247, 11257, 11437, 11447, 11457, 11637, 11647, 11657, 11837, 11847, 11857 };
- DWORD dwVnum = cufar_armuri[number(0, 11)];
- AutoGiveItem(dwVnum);
- }
- if (GetLevel() >= 46 && GetLevel() <=70)
- {
- const static DWORD cufar_armuri[16] = { 11267, 11277, 11287, 11467, 11477, 11487, 11667, 11677, 11687, 11867, 11877, 11887, 11297, 11497, 11697, 11897 };
- DWORD dwVnum = cufar_armuri[number(0, 15)];
- AutoGiveItem(dwVnum);
- }
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, "[Sistem] Nu ai nivelul necesar pentru a deschide acest cufat (nivel: 5-70).");
- return false;
- }
- }
- break;
- case 40495:
- {
- if (GetLevel() > 4 && GetLevel() < 71)
- {
- {
- if (GetLevel() >= 5 && GetLevel() <=20)
- {
- const static DWORD cufar_arme[27] = { 17, 27, 37, 47, 57, 1007, 1107, 1027, 2017, 2027, 2037, 2047, 3007, 3017, 3027, 3037, 3047, 4007, 4017, 5007, 5017, 5027, 7007, 7017, 7027, 7037, 7047 };
- DWORD dwVnum = cufar_arme[number(0, 26)];
- AutoGiveItem(dwVnum);
- }
- if (GetLevel() >= 21 && GetLevel() <=45)
- {
- const static DWORD cufar_arme[26] = { 67, 77, 87, 97, 1037, 1047, 1057, 1067, 2057, 2067, 2077, 2087, 2097, 3057, 3067, 3077, 3087, 3097, 5027, 5037, 5047, 5057, 7057, 7067, 7077, 7087 };
- DWORD dwVnum = cufar_arme[number(0, 25)];
- AutoGiveItem(dwVnum);
- }
- if (GetLevel() >= 46 && GetLevel() <=70)
- {
- const static DWORD cufar_arme[32] = { 117, 127, 137, 1077, 1087, 1097, 2107, 2117, 2127, 3107, 3127, 5067, 5077, 5087, 7097, 7107, 7117, 7127, 145, 3135, 155, 167, 247, 1105, 1117, 2145, 2137, 3147, 5097, 5105, 7137, 7145 };
- DWORD dwVnum = cufar_arme[number(0, 31)];
- AutoGiveItem(dwVnum);
- }
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, "[Sistem] Nu ai nivelul necesar pentru a deschide acest cufat (nivel: 5-70).");
- return false;
- }
- }
- break;
- case 50183:
- {
- if (GetLevel() > 4 && GetLevel() < 127)
- {
- {
- if (GetLevel() >= 5 && GetLevel() <=60)
- {
- const static DWORD cufar_carti[10] = { 50300, 50300, 50300, 50300, 50300, 50300, 50300, 50513, 40480, 40480 };
- DWORD dwVnum = cufar_carti[number(0, 9)];
- AutoGiveItem(dwVnum);
- item->SetCount(item->GetCount() - 1);
- }
- if (GetLevel() >= 61 && GetLevel() <=127)
- {
- const static DWORD cufar_carti[9] = { 50300, 50300, 50300, 50300, 50513, 50513, 40480, 40480, 40480 };
- DWORD dwVnum = cufar_carti[number(0, 8)];
- AutoGiveItem(dwVnum);
- item->SetCount(item->GetCount() - 1);
- }
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, "[Sistem] Nu ai nivelul necesar pentru a deschide acest cufat (nivel: 5-127).");
- return false;
- }
- }
- break;
- case 50182:
- {
- if (GetLevel() > 4 && GetLevel() < 127)
- {
- {
- if (GetLevel() >= 5 && GetLevel() <=40)
- {
- const static DWORD cufar_pietre[14] = { 28330, 28331, 28332, 28333, 28334, 28335, 28336, 28337, 28338, 28339, 28340, 28341, 28342, 28343 };
- DWORD dwVnum = cufar_pietre[number(0, 13)];
- AutoGiveItem(dwVnum);
- }
- if (GetLevel() >= 41 && GetLevel() <=127)
- {
- const static DWORD cufar_pietre[14] = { 28430, 28431, 28432, 28433, 28434, 28435, 28436, 28437, 28438, 28439, 28440, 28441, 28442, 28443 };
- DWORD dwVnum = cufar_pietre[number(0, 13)];
- AutoGiveItem(dwVnum);
- }
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, "[Sistem] Nu ai nivelul necesar pentru a deschide acest cufat (nivel: 5-127).");
- return false;
- }
- }
- break;
- case 70016:
- {
- if (GetLevel() > 30 && GetLevel() < 127)
- {
- {
- if (GetLevel() >= 30 && GetLevel() <=200)
- {
- const static DWORD cufar_carti_pet[3] = { 55003, 55004, 55005 };
- DWORD dwVnum = cufar_carti_pet[number(0, 2)];
- AutoGiveItem(dwVnum);
- item->SetCount(item->GetCount() - 1);
- }
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, "[Sistem] Nu ai nivelul necesar pentru a deschide acest cufat (nivel: 30-200).");
- return false;
- }
- }
- break;
- }
- if (item->GetVnum() > 50800 && item->GetVnum() <= 50820)
- {
- if (test_server)
- sys_log (0, "ADD addtional effect : vnum(%d) subtype(%d)", item->GetOriginalVnum(), item->GetSubType());
- int affect_type = AFFECT_EXP_BONUS_EURO_FREE;
- int apply_type = aApplyInfo[item->GetValue(0)].bPointType;
- int apply_value = item->GetValue(2);
- int apply_duration = item->GetValue(1);
- switch (item->GetSubType())
- {
- case USE_ABILITY_UP:
- if (FindAffect(affect_type, apply_type))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Deja Functioneaza."));
- return false;
- }
- {
- switch (item->GetValue(0))
- {
- case APPLY_MOV_SPEED:
- AddAffect(affect_type, apply_type, apply_value, AFF_MOV_SPEED_POTION, apply_duration, 0, true, true);
- EffectPacket(SE_DXUP_PURPLE); //purple potion
- break;
- case APPLY_ATT_SPEED:
- AddAffect(affect_type, apply_type, apply_value, AFF_ATT_SPEED_POTION, apply_duration, 0, true, true);
- EffectPacket(SE_SPEEDUP_GREEN); //green potion
- break;
- case APPLY_STR:
- case APPLY_DEX:
- case APPLY_CON:
- case APPLY_INT:
- case APPLY_CAST_SPEED:
- case APPLY_RESIST_MAGIC:
- case APPLY_ATT_GRADE_BONUS:
- case APPLY_DEF_GRADE_BONUS:
- AddAffect(affect_type, apply_type, apply_value, 0, apply_duration, 0, true, true);
- break;
- }
- }
- if (GetDungeon())
- GetDungeon()->UsePotion(this);
- if (GetWarMap())
- GetWarMap()->UsePotion(this, item);
- #ifdef LEARN_BOOK_FIX
- item->SetCount(item->GetCount() - 1);
- #endif
- break;
- #ifdef ENABLE_AFFECT_ITEMS_PLUS
- case USE_AFFECT :
- {
- #ifdef ENABLE_YMIR_AFFECT_FIX
- if ((CheckTimeUsed(item) == false)) { return false; }
- #endif
- int affect_type = item->GetValue(0);
- int apply_type = aApplyInfo[item->GetValue(1)].bPointType;
- int apply_value = item->GetValue(2);
- int affect_state_socket = 0;
- CAffect* pAffect = FindAffect(affect_type, apply_type);
- if (pAffect == NULL)
- {
- AddAffect(affect_type, apply_type, apply_value, item->GetID(), INFINITE_AFFECT_DURATION, 0, false);
- item->SetSocket(affect_state_socket, 1);
- item->Lock(true);
- }
- else
- {
- if (item->GetID() == pAffect->dwFlag)
- {
- RemoveAffect( pAffect );
- item->Lock(false);
- item->SetSocket(affect_state_socket, 0);
- }
- else
- {
- LPITEM old = FindItemByID( pAffect->dwFlag );
- if (NULL != old)
- {
- old->Lock(false);
- old->SetSocket(affect_state_socket, 0);
- }
- RemoveAffect(pAffect);
- AddAffect(affect_type, apply_type, apply_value, item->GetID(), INFINITE_AFFECT_DURATION, 0, false);
- item->SetSocket(affect_state_socket, 1);
- item->Lock(true);
- }
- }
- }
- break;
- #else
- case USE_AFFECT :
- {
- if (FindAffect(item->GetValue(0), aApplyInfo[item->GetValue(1)].bPointType))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Deja Functioneaza."));
- }
- else
- {
- // PC_BANG_ITEM_ADD
- if (item->IsPCBangItem() == true)
- {
- if (CPCBangManager::instance().IsPCBangIP(GetDesc()->GetHostName()) == false)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This book can be found at low levels of metin."));
- return false;
- }
- }
- // END_PC_BANG_ITEM_ADD
- AddAffect(item->GetValue(0), aApplyInfo[item->GetValue(1)].bPointType, item->GetValue(2), 0, item->GetValue(3), 0, false);
- item->SetCount(item->GetCount() - 1);
- }
- }
- break;
- #endif
- case USE_POTION_NODELAY:
- {
- if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
- {
- if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit") > 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Can not be used in battle sides"));
- return false;
- }
- switch (item->GetVnum())
- {
- case 70020 :
- case 71018 :
- case 71019 :
- case 71020 :
- if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit_count") < 10000)
- {
- if (m_nPotionLimit <= 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti folosi licori în arena luptelor. "));
- return false;
- }
- }
- break;
- default :
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- return false;
- break;
- }
- }
- bool used = false;
- if (item->GetValue(0) != 0) // HP
- {
- if (GetHP() < GetMaxHP())
- {
- PointChange(POINT_HP, item->GetValue(0) * (100 + GetPoint(POINT_POTION_BONUS)) / 100);
- EffectPacket(SE_HPUP_RED);
- used = TRUE;
- }
- }
- if (item->GetValue(1) != 0) // SP
- {
- if (GetSP() < GetMaxSP())
- {
- PointChange(POINT_SP, item->GetValue(1) * (100 + GetPoint(POINT_POTION_BONUS)) / 100);
- EffectPacket(SE_SPUP_BLUE);
- used = TRUE;
- }
- }
- if (item->GetValue(3) != 0) // HP %
- {
- if (GetHP() < GetMaxHP())
- {
- PointChange(POINT_HP, item->GetValue(3) * GetMaxHP() / 100);
- EffectPacket(SE_HPUP_RED);
- used = TRUE;
- }
- }
- if (item->GetValue(4) != 0) // SP %
- {
- if (GetSP() < GetMaxSP())
- {
- PointChange(POINT_SP, item->GetValue(4) * GetMaxSP() / 100);
- EffectPacket(SE_SPUP_BLUE);
- used = TRUE;
- }
- }
- if (used)
- {
- if (item->GetVnum() == 50085 || item->GetVnum() == 50086)
- {
- if (test_server)
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("All items were used"));
- SetUseSeedOrMoonBottleTime();
- }
- if (GetDungeon())
- GetDungeon()->UsePotion(this);
- if (GetWarMap())
- GetWarMap()->UsePotion(this, item);
- m_nPotionLimit--;
- //RESTRICT_USE_SEED_OR_MOONBOTTLE
- item->SetCount(item->GetCount() - 1);
- //END_RESTRICT_USE_SEED_OR_MOONBOTTLE
- }
- }
- break;
- }
- return true;
- }
- if (item->GetVnum() >= 27863 && item->GetVnum() <= 27883)
- {
- if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- return false;
- }
- }
- if (test_server)
- {
- //sys_log (0, "USE_ITEM %s Type %d SubType %d vnum %d", item->GetName(), item->GetType(), item->GetSubType(), item->GetOriginalVnum());
- }
- switch (item->GetSubType())
- {
- case USE_TIME_CHARGE_PER:
- {
- LPITEM pDestItem = GetItem(DestCell);
- if (NULL == pDestItem)
- {
- return false;
- }
- if (pDestItem->IsDragonSoul())
- {
- int ret;
- char buf[128];
- if (item->GetVnum() == DRAGON_HEART_VNUM)
- {
- ret = pDestItem->GiveMoreTime_Per((float)item->GetSocket(ITEM_SOCKET_CHARGING_AMOUNT_IDX));
- }
- else
- {
- ret = pDestItem->GiveMoreTime_Per((float)item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
- }
- if (ret > 0)
- {
- if (item->GetVnum() == DRAGON_HEART_VNUM)
- {
- sprintf(buf, "Inc %ds by item{VN:%d SOC%d:%d}", ret, item->GetVnum(), ITEM_SOCKET_CHARGING_AMOUNT_IDX, item->GetSocket(ITEM_SOCKET_CHARGING_AMOUNT_IDX));
- }
- else
- {
- sprintf(buf, "Inc %ds by item{VN:%d VAL%d:%d}", ret, item->GetVnum(), ITEM_VALUE_CHARGING_AMOUNT_IDX, item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
- }
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dÃÊ ¸¸Å ÃæÀüµÇ¾ú½À´Ï´Ù."), ret);
- item->SetCount(item->GetCount() - 1);
- LogManager::instance().ItemLog(this, item, "DS_CHARGING_SUCCESS", buf);
- return true;
- }
- else
- {
- if (item->GetVnum() == DRAGON_HEART_VNUM)
- {
- sprintf(buf, "No change by item{VN:%d SOC%d:%d}", item->GetVnum(), ITEM_SOCKET_CHARGING_AMOUNT_IDX, item->GetSocket(ITEM_SOCKET_CHARGING_AMOUNT_IDX));
- }
- else
- {
- sprintf(buf, "No change by item{VN:%d VAL%d:%d}", item->GetVnum(), ITEM_VALUE_CHARGING_AMOUNT_IDX, item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
- }
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Alchimie>Puterea Pietrei Dragon este incarcata!"));
- LogManager::instance().ItemLog(this, item, "DS_CHARGING_FAILED", buf);
- return false;
- }
- }
- else
- return false;
- }
- break;
- case USE_TIME_CHARGE_FIX:
- {
- LPITEM pDestItem = GetItem(DestCell);
- if (NULL == pDestItem)
- {
- return false;
- }
- // ¿ì¼± ¿ëÈ¥¼®¿¡ °üÇØ¼¸¸ Çϵµ·Ï ÇÑ´Ù.
- if (pDestItem->IsDragonSoul())
- {
- int ret = pDestItem->GiveMoreTime_Fix(item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
- char buf[128];
- if (ret)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dÃÊ ¸¸Å ÃæÀüµÇ¾ú½À´Ï´Ù."), ret);
- sprintf(buf, "Increase %ds by item{VN:%d VAL%d:%d}", ret, item->GetVnum(), ITEM_VALUE_CHARGING_AMOUNT_IDX, item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
- LogManager::instance().ItemLog(this, item, "DS_CHARGING_SUCCESS", buf);
- item->SetCount(item->GetCount() - 1);
- return true;
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("ÃæÀüÇÒ ¼ö ¾ø½À´Ï´Ù."));
- sprintf(buf, "No change by item{VN:%d VAL%d:%d}", item->GetVnum(), ITEM_VALUE_CHARGING_AMOUNT_IDX, item->GetValue(ITEM_VALUE_CHARGING_AMOUNT_IDX));
- LogManager::instance().ItemLog(this, item, "DS_CHARGING_FAILED", buf);
- return false;
- }
- }
- else
- return false;
- }
- break;
- case USE_EXTEND_TIME:
- {
- LPITEM item2;
- if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
- return false;
- if (item2->IsExchanging() || item2->IsEquipped())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use this item when you exchange or when your object is equipped."));
- return false;
- }
- if (item2->GetType() != ITEM_COSTUME || (item2->GetSubType() != COSTUME_BODY && item2->GetSubType() != COSTUME_HAIR))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't use this item for this object."));
- return false;
- }
- item2->SetSocket(0, item2->GetSocket(0) + item->GetValue(0));
- item->SetCount(item->GetCount() - 1);
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Extended time has been added!"));
- }
- break;
- case USE_SPECIAL:
- switch (item->GetVnum())
- {
- #ifdef ENABLE_ANTI_EXP_SYSTEM
- case ANTIEXP_RING_ID:
- {
- GetBlockExpValue()?SetBlockExpValue(0):SetBlockExpValue(1);
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("blockexp_set_status%s"), GetBlockExpValue()?LC_TEXT("blockexp_activated_text"):LC_TEXT("blockexp_deactivated_text"));
- UpdatePacket();
- }
- break;
- #ifdef ENABLE_EXP_BOTTLE_FEATURE
- case EXP_BOTTLE_ID:
- {
- if(HasBlockedExp() || GetLevel() >= gPlayerMaxLevel || GetNextExp() > EXP_BOTTLE_STORAGE_LIMIT)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("blockexp_can_not_use"));
- return false;
- }
- LPITEM bottle = FindSpecifyItem(EXP_BOTTLE_ID);
- if(!bottle)
- return false;
- if(bottle->GetSocket(1) > 0)
- {
- int exp = GetExp();
- int next_step = GetNextExp();
- int toadd = next_step - exp;
- int realtoadd = 0;
- if(bottle->GetSocket(1) < toadd)
- realtoadd = bottle->GetSocket(1);
- else
- realtoadd = toadd;
- PointChange(POINT_EXP, realtoadd, true);
- bottle->SetSocket(1, bottle->GetSocket(1)-realtoadd);
- }
- }
- break;
- #endif
- #endif
- //Å©¸®½º¸¶½º ¶õÁÖ
- case ITEM_NOG_POCKET:
- {
- /*
- ¶õÁÖ´É·ÂÄ¡ : item_proto value ÀǹÌ
- À̵¿¼Óµµ value 1
- °ø°Ý·Â value 2
- °æÇèÄ¡ value 3
- Áö¼Ó½Ã°£ value 0 (´ÜÀ§ ÃÊ)
- */
- if (FindAffect(AFFECT_NOG_ABILITY))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Deja Functioneaza."));
- return false;
- }
- long time = item->GetValue(0);
- long moveSpeedPer = item->GetValue(1);
- long attPer = item->GetValue(2);
- long expPer = item->GetValue(3);
- AddAffect(AFFECT_NOG_ABILITY, POINT_MOV_SPEED, moveSpeedPer, AFF_MOV_SPEED_POTION, time, 0, true, true);
- EffectPacket(SE_DXUP_PURPLE);
- AddAffect(AFFECT_NOG_ABILITY, POINT_MALL_ATTBONUS, attPer, AFF_NONE, time, 0, true, true);
- AddAffect(AFFECT_NOG_ABILITY, POINT_MALL_EXPBONUS, expPer, AFF_NONE, time, 0, true, true);
- item->SetCount(item->GetCount() - 1);
- }
- break;
- //¶ó¸¶´Ü¿ë »çÅÁ
- case ITEM_RAMADAN_CANDY:
- {
- /*
- »çÅÁ´É·ÂÄ¡ : item_proto value ÀǹÌ
- À̵¿¼Óµµ value 1
- °ø°Ý·Â value 2
- °æÇèÄ¡ value 3
- Áö¼Ó½Ã°£ value 0 (´ÜÀ§ ÃÊ)
- */
- long time = item->GetValue(0);
- long moveSpeedPer = item->GetValue(1);
- long attPer = item->GetValue(2);
- long expPer = item->GetValue(3);
- AddAffect(AFFECT_RAMADAN_ABILITY, POINT_MOV_SPEED, moveSpeedPer, AFF_MOV_SPEED_POTION, time, 0, true, true);
- AddAffect(AFFECT_RAMADAN_ABILITY, POINT_MALL_ATTBONUS, attPer, AFF_NONE, time, 0, true, true);
- AddAffect(AFFECT_RAMADAN_ABILITY, POINT_MALL_EXPBONUS, expPer, AFF_NONE, time, 0, true, true);
- item->SetCount(item->GetCount() - 1);
- }
- break;
- case ITEM_MARRIAGE_RING:
- {
- marriage::TMarriage* pMarriage = marriage::CManager::instance().Get(GetPlayerID());
- if (pMarriage)
- {
- if (pMarriage->ch1 != NULL)
- {
- if (CArenaManager::instance().IsArenaMap(pMarriage->ch1->GetMapIndex()) == true)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- break;
- }
- }
- if (pMarriage->ch2 != NULL)
- {
- if (CArenaManager::instance().IsArenaMap(pMarriage->ch2->GetMapIndex()) == true)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- break;
- }
- }
- int consumeSP = CalculateConsumeSP(this);
- if (consumeSP < 0)
- return false;
- PointChange(POINT_SP, -consumeSP, false);
- WarpToPID(pMarriage->GetOther(GetPlayerID()));
- }
- else
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu te poti casatori decat daca ai inelul de logodna"));
- }
- break;
- case UNIQUE_ITEM_CAPE_OF_COURAGE:
- case REWARD_BOX_UNIQUE_ITEM_CAPE_OF_COURAGE:
- AggregateMonster();
- item->SetCount(item->GetCount()-0);
- break;
- case UNIQUE_ITEM_WHITE_FLAG:
- ForgetMyAttacker();
- item->SetCount(item->GetCount()-1);
- break;
- case UNIQUE_ITEM_TREASURE_BOX:
- break;
- case 30094:
- case 30095:
- case 30096:
- // º¹ÁÖ¸Ó´Ï
- {
- const int MAX_BAG_INFO = 26;
- static struct LuckyBagInfo
- {
- DWORD count;
- int prob;
- DWORD vnum;
- } b1[MAX_BAG_INFO] =
- {
- { 1000, 302, 1 },
- { 10, 150, 27002 },
- { 10, 75, 27003 },
- { 10, 100, 27005 },
- { 10, 50, 27006 },
- { 10, 80, 27001 },
- { 10, 50, 27002 },
- { 10, 80, 27004 },
- { 10, 50, 27005 },
- { 1, 10, 50300 },
- { 1, 6, 92 },
- { 1, 2, 132 },
- { 1, 6, 1052 },
- { 1, 2, 1092 },
- { 1, 6, 2082 },
- { 1, 2, 2122 },
- { 1, 6, 3082 },
- { 1, 2, 3122 },
- { 1, 6, 5052 },
- { 1, 2, 5082 },
- { 1, 6, 7082 },
- { 1, 2, 7122 },
- { 1, 1, 11282 },
- { 1, 1, 11482 },
- { 1, 1, 11682 },
- { 1, 1, 11882 },
- };
- struct LuckyBagInfo b2[MAX_BAG_INFO] =
- {
- { 1000, 302, 1 },
- { 10, 150, 27002 },
- { 10, 75, 27002 },
- { 10, 100, 27005 },
- { 10, 50, 27005 },
- { 10, 80, 27001 },
- { 10, 50, 27002 },
- { 10, 80, 27004 },
- { 10, 50, 27005 },
- { 1, 10, 50300 },
- { 1, 6, 92 },
- { 1, 2, 132 },
- { 1, 6, 1052 },
- { 1, 2, 1092 },
- { 1, 6, 2082 },
- { 1, 2, 2122 },
- { 1, 6, 3082 },
- { 1, 2, 3122 },
- { 1, 6, 5052 },
- { 1, 2, 5082 },
- { 1, 6, 7082 },
- { 1, 2, 7122 },
- { 1, 1, 11282 },
- { 1, 1, 11482 },
- { 1, 1, 11682 },
- { 1, 1, 11882 },
- };
- LuckyBagInfo * bi = NULL;
- if (LC_IsHongKong())
- bi = b2;
- else
- bi = b1;
- int pct = number(1, 1000);
- int i;
- for (i=0;i<MAX_BAG_INFO;i++)
- {
- if (pct <= bi[i].prob)
- break;
- pct -= bi[i].prob;
- }
- if (i>=MAX_BAG_INFO)
- return false;
- if (bi[i].vnum == 50300)
- {
- // ½ºÅ³¼ö·Ã¼´Â Ư¼öÇÏ°Ô ÁØ´Ù.
- GiveRandomSkillBook();
- }
- else if (bi[i].vnum == 1)
- {
- PointChange(POINT_GOLD, 1000, true);
- }
- else
- {
- AutoGiveItem(bi[i].vnum, bi[i].count);
- }
- item->SetCount(item->GetCount() - 1);
- }
- break;
- case 50004:
- {
- if (item->GetSocket(0))
- {
- item->SetSocket(0, item->GetSocket(0) + 1);
- }
- else
- {
- int iMapIndex = GetMapIndex();
- PIXEL_POSITION pos;
- if (SECTREE_MANAGER::instance().GetRandomLocation(iMapIndex, pos, 700))
- {
- item->SetSocket(0, 1);
- item->SetSocket(1, pos.x);
- item->SetSocket(2, pos.y);
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This improvement does not work with current events"));
- return false;
- }
- }
- int dist = 0;
- float distance = (DISTANCE_SQRT(GetX()-item->GetSocket(1), GetY()-item->GetSocket(2)));
- if (distance < 1000.0f)
- {
- // ¹ß°ß!
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("The fish disappeared."));
- struct TEventStoneInfo
- {
- DWORD dwVnum;
- int count;
- int prob;
- };
- const int EVENT_STONE_MAX_INFO = 15;
- TEventStoneInfo info_10[EVENT_STONE_MAX_INFO] =
- {
- { 27001, 10, 8 },
- { 27004, 10, 6 },
- { 27002, 10, 12 },
- { 27005, 10, 12 },
- { 27100, 1, 9 },
- { 27103, 1, 9 },
- { 27101, 1, 10 },
- { 27104, 1, 10 },
- { 27999, 1, 12 },
- { 25040, 1, 4 },
- { 27410, 1, 0 },
- { 27600, 1, 0 },
- { 25100, 1, 0 },
- { 50001, 1, 0 },
- { 50003, 1, 1 },
- };
- TEventStoneInfo info_7[EVENT_STONE_MAX_INFO] =
- {
- { 27001, 10, 1 },
- { 27004, 10, 1 },
- { 27004, 10, 9 },
- { 27005, 10, 9 },
- { 27100, 1, 5 },
- { 27103, 1, 5 },
- { 27101, 1, 10 },
- { 27104, 1, 10 },
- { 27999, 1, 14 },
- { 25040, 1, 5 },
- { 27410, 1, 5 },
- { 27600, 1, 5 },
- { 25100, 1, 5 },
- { 50001, 1, 0 },
- { 50003, 1, 5 },
- };
- TEventStoneInfo info_4[EVENT_STONE_MAX_INFO] =
- {
- { 27001, 10, 0 },
- { 27004, 10, 0 },
- { 27002, 10, 0 },
- { 27005, 10, 0 },
- { 27100, 1, 0 },
- { 27103, 1, 0 },
- { 27101, 1, 0 },
- { 27104, 1, 0 },
- { 27999, 1, 25 },
- { 25040, 1, 0 },
- { 27410, 1, 0 },
- { 27600, 1, 0 },
- { 25100, 1, 15 },
- { 50001, 1, 10 },
- { 50003, 1, 50 },
- };
- {
- TEventStoneInfo* info;
- if (item->GetSocket(0) <= 4)
- info = info_4;
- else if (item->GetSocket(0) <= 7)
- info = info_7;
- else
- info = info_10;
- int prob = number(1, 100);
- for (int i = 0; i < EVENT_STONE_MAX_INFO; ++i)
- {
- if (!info[i].prob)
- continue;
- if (prob <= info[i].prob)
- {
- if (info[i].dwVnum == 50001)
- {
- DWORD * pdw = M2_NEW DWORD[2];
- pdw[0] = info[i].dwVnum;
- pdw[1] = info[i].count;
- DBManager::instance().ReturnQuery(QID_LOTTO, GetPlayerID(), pdw,
- "INSERT INTO lotto_list VALUES(0, 'server%s', %u, NOW())",
- get_table_postfix(), GetPlayerID());
- }
- else
- AutoGiveItem(info[i].dwVnum, info[i].count);
- break;
- }
- prob -= info[i].prob;
- }
- }
- char chatbuf[CHAT_MAX_LEN + 1];
- int len = snprintf(chatbuf, sizeof(chatbuf), "StoneDetect %u 0 0", (DWORD)GetVID());
- if (len < 0 || len >= (int) sizeof(chatbuf))
- len = sizeof(chatbuf) - 1;
- ++len;
- TPacketGCChat pack_chat;
- pack_chat.header = HEADER_GC_CHAT;
- pack_chat.size = sizeof(TPacketGCChat) + len;
- pack_chat.type = CHAT_TYPE_COMMAND;
- pack_chat.id = 0;
- pack_chat.bEmpire = GetDesc()->GetEmpire();
- //pack_chat.id = vid;
- TEMP_BUFFER buf;
- buf.write(&pack_chat, sizeof(TPacketGCChat));
- buf.write(chatbuf, len);
- PacketAround(buf.read_peek(), buf.size());
- ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (DETECT_EVENT_STONE) 1");
- return true;
- }
- else if (distance < 20000)
- dist = 1;
- else if (distance < 70000)
- dist = 2;
- else
- dist = 3;
- // ¸¹ÀÌ »ç¿ëÇßÀ¸¸é »ç¶óÁø´Ù.
- const int STONE_DETECT_MAX_TRY = 10;
- if (item->GetSocket(0) >= STONE_DETECT_MAX_TRY)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("The object disappears."));
- ITEM_MANAGER::instance().RemoveItem(item, "REMOVE (DETECT_EVENT_STONE) 0");
- AutoGiveItem(27002);
- return true;
- }
- if (dist)
- {
- char chatbuf[CHAT_MAX_LEN + 1];
- int len = snprintf(chatbuf, sizeof(chatbuf),
- "StoneDetect %u %d %d",
- (DWORD)GetVID(), dist, (int)GetDegreeFromPositionXY(GetX(), item->GetSocket(2), item->GetSocket(1), GetY()));
- if (len < 0 || len >= (int) sizeof(chatbuf))
- len = sizeof(chatbuf) - 1;
- ++len;
- TPacketGCChat pack_chat;
- pack_chat.header = HEADER_GC_CHAT;
- pack_chat.size = sizeof(TPacketGCChat) + len;
- pack_chat.type = CHAT_TYPE_COMMAND;
- pack_chat.id = 0;
- pack_chat.bEmpire = GetDesc()->GetEmpire();
- //pack_chat.id = vid;
- TEMP_BUFFER buf;
- buf.write(&pack_chat, sizeof(TPacketGCChat));
- buf.write(chatbuf, len);
- PacketAround(buf.read_peek(), buf.size());
- }
- }
- break;
- case 27987: // Á¶°³
- // 50 µ¹Á¶°¢ 47990
- // 30 ²Î
- // 10 ¹éÁøÁÖ 47992
- // 7 ûÁøÁÖ 47993
- // 3 ÇÇÁøÁÖ 47994
- {
- item->SetCount(item->GetCount() - 1);
- int r = number(1, 100);
- if (r <= 50)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai deschis o scoica."));
- AutoGiveItem(27990);
- }
- else
- {
- const int prob_table_euckr[] =
- {
- 80, 90, 97
- };
- const int prob_table_gb2312[] =
- {
- 95, 97, 99
- };
- const int * prob_table = !g_iUseLocale ? prob_table_euckr : prob_table_gb2312;
- if (r <= prob_table[0])
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai deschis o scoica goala."));
- }
- else if (r <= prob_table[1])
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Se pare ca ai gasit o scoica Alba"));
- AutoGiveItem(27992);
- }
- else if (r <= prob_table[2])
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Se pare ca ai gasit o scoica Albastra"));
- AutoGiveItem(27993);
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Se pare ca ai gasit o scoica Rosie"));
- AutoGiveItem(27994);
- }
- }
- }
- break;
- case 71013: // ÃàÁ¦¿ëÆøÁ×
- CreateFly(number(FLY_FIREWORK1, FLY_FIREWORK6), this);
- item->SetCount(item->GetCount() - 1);
- break;
- case 50100: // ÆøÁ×
- case 50101:
- case 50102:
- case 50103:
- case 50104:
- case 50105:
- case 50106:
- CreateFly(item->GetVnum() - 50100 + FLY_FIREWORK1, this);
- item->SetCount(item->GetCount() - 1);
- break;
- case 50200: // º¸µû¸®
- if (LC_IsYMIR() == true || LC_IsKorea() == true)
- {
- if (IS_BOTARYABLE_ZONE(GetMapIndex()) == true)
- {
- __OpenPrivateShop();
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide magazin in acest loc"));
- }
- }
- else
- {
- __OpenPrivateShop();
- }
- break;
- case fishing::FISH_MIND_PILL_VNUM:
- AddAffect(AFFECT_FISH_MIND_PILL, POINT_NONE, 0, AFF_FISH_MIND, 20*60, 0, true);
- item->SetCount(item->GetCount() - 1);
- break;
- case 50301: // Åë¼Ö·Â ¼ö·Ã¼
- case 50302:
- case 50303:
- {
- if (IsPolymorphed() == true)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
- return false;
- }
- int lv = GetSkillLevel(SKILL_LEADERSHIP);
- if (lv < item->GetValue(0))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Competenta este prea mica pentru a fi ridicata cu o carte."));
- return false;
- }
- if (lv >= item->GetValue(1))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu mai poti urca aceasta competenta."));
- return false;
- }
- if (LearnSkillByBook(SKILL_LEADERSHIP))
- {
- item->SetCount(item->GetCount() - 1);
- int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
- if (distribution_test_server) iReadDelay /= 3;
- SetSkillNextReadTime(SKILL_LEADERSHIP, get_global_time() + iReadDelay);
- }
- }
- break;
- case 50304: // ¿¬°è±â ¼ö·Ã¼
- case 50305:
- case 50306:
- {
- if (IsPolymorphed())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
- return false;
- }
- if (GetSkillLevel(SKILL_COMBO) == 0 && GetLevel() < 30)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti invata aceasta carte pana la nivel 30."));
- return false;
- }
- if (GetSkillLevel(SKILL_COMBO) == 1 && GetLevel() < 50)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti invata aceasta carte pana la nivel 50."));
- return false;
- }
- if (GetSkillLevel(SKILL_COMBO) >= 2)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu pot folosi aceasta carte."));
- return false;
- }
- int iPct = item->GetValue(0);
- if (LearnSkillByBook(SKILL_COMBO, iPct))
- {
- item->SetCount(item->GetCount() - 1);
- int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
- if (distribution_test_server) iReadDelay /= 3;
- SetSkillNextReadTime(SKILL_COMBO, get_global_time() + iReadDelay);
- }
- }
- break;
- case 50311: // ¾ð¾î ¼ö·Ã¼
- case 50312:
- case 50313:
- {
- if (IsPolymorphed())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
- return false;
- }
- DWORD dwSkillVnum = item->GetValue(0);
- int iPct = MINMAX(0, item->GetValue(1), 100);
- if (GetSkillLevel(dwSkillVnum)>=20 || dwSkillVnum-SKILL_LANGUAGE1+1 == GetEmpire())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti citi aceasta carte."));
- return false;
- }
- if (LearnSkillByBook(dwSkillVnum, iPct))
- {
- item->SetCount(item->GetCount() - 1);
- int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
- if (distribution_test_server) iReadDelay /= 3;
- SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
- }
- }
- break;
- case 50061 : // ÀϺ» ¸» ¼Òȯ ½ºÅ³ ¼ö·Ã¼
- {
- if (IsPolymorphed())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
- return false;
- }
- DWORD dwSkillVnum = item->GetValue(0);
- int iPct = MINMAX(0, item->GetValue(1), 100);
- if (GetSkillLevel(dwSkillVnum) >= 10)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aceasta competenta este deja la nivelul maxim."));
- return false;
- }
- if (LearnSkillByBook(dwSkillVnum, iPct))
- {
- item->SetCount(item->GetCount() - 1);
- int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
- if (distribution_test_server) iReadDelay /= 3;
- SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
- }
- }
- break;
- case 50314: case 50315: case 50316:
- case 50323: case 50324:
- case 50325: case 50326:
- {
- if (IsPolymorphed() == true)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
- return false;
- }
- int iSkillLevelLowLimit = item->GetValue(0);
- int iSkillLevelHighLimit = item->GetValue(1);
- int iPct = MINMAX(0, item->GetValue(2), 100);
- int iLevelLimit = item->GetValue(3);
- DWORD dwSkillVnum = 0;
- switch (item->GetVnum())
- {
- case 50314: case 50315: case 50316:
- dwSkillVnum = SKILL_POLYMORPH;
- break;
- case 50323: case 50324:
- dwSkillVnum = SKILL_ADD_HP;
- break;
- case 50325: case 50326:
- dwSkillVnum = SKILL_RESIST_PENETRATE;
- break;
- default:
- return false;
- }
- if (0 == dwSkillVnum)
- return false;
- if (GetLevel() < iLevelLimit)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You must have the consent of the user."));
- return false;
- }
- if (GetSkillLevel(dwSkillVnum) >= 40)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aceasta competenta este deja la nivelul maxim."));
- return false;
- }
- if (GetSkillLevel(dwSkillVnum) < iSkillLevelLowLimit)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Competenta este prea mica pentru a fi ridicata cu o carte."));
- return false;
- }
- if (GetSkillLevel(dwSkillVnum) >= iSkillLevelHighLimit)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aceasta competenta este deja la nivelul maxim."));
- return false;
- }
- if (LearnSkillByBook(dwSkillVnum, iPct))
- {
- item->SetCount(item->GetCount() - 1);
- int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
- if (distribution_test_server) iReadDelay /= 3;
- SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
- }
- }
- break;
- case 50902:
- case 50903:
- case 50904:
- {
- if (IsPolymorphed())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
- return false;
- }
- DWORD dwSkillVnum = SKILL_CREATE;
- int iPct = MINMAX(0, item->GetValue(1), 100);
- if (GetSkillLevel(dwSkillVnum)>=40)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aceasta competenta este deja la nivelul maxim."));
- return false;
- }
- if (LearnSkillByBook(dwSkillVnum, iPct))
- {
- item->SetCount(item->GetCount() - 1);
- int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
- if (distribution_test_server) iReadDelay /= 3;
- SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
- if (test_server)
- {
- ChatPacket(CHAT_TYPE_INFO, "[TEST_SERVER] Success to learn skill ");
- }
- }
- else
- {
- if (test_server)
- {
- ChatPacket(CHAT_TYPE_INFO, "[TEST_SERVER] Failed to learn skill ");
- }
- }
- }
- break;
- // MINING
- case ITEM_MINING_SKILL_TRAIN_BOOK:
- {
- if (IsPolymorphed())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
- return false;
- }
- DWORD dwSkillVnum = SKILL_MINING;
- int iPct = MINMAX(0, item->GetValue(1), 100);
- if (GetSkillLevel(dwSkillVnum)>=40)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Aceasta competenta este deja la nivelul maxim."));
- return false;
- }
- if (LearnSkillByBook(dwSkillVnum, iPct))
- {
- item->SetCount(item->GetCount() - 1);
- int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
- if (distribution_test_server) iReadDelay /= 3;
- SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
- }
- }
- break;
- // END_OF_MINING
- case ITEM_HORSE_SKILL_TRAIN_BOOK:
- {
- if (IsPolymorphed())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu_Cand_Esti_Transformat."));
- return false;
- }
- DWORD dwSkillVnum = SKILL_HORSE;
- int iPct = MINMAX(0, item->GetValue(1), 100);
- if (GetLevel() < 50)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You will be able to improve your horsemanship."));
- return false;
- }
- if (!test_server && get_global_time() < GetSkillNextReadTime(dwSkillVnum))
- {
- if (FindAffect(AFFECT_SKILL_NO_BOOK_DELAY))
- {
- RemoveAffect(AFFECT_SKILL_NO_BOOK_DELAY);
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Spiritul meu este pur ! Se pare ca am scapat de blestem."));
- }
- else
- {
- SkillLearnWaitMoreTimeMessage(GetSkillNextReadTime(dwSkillVnum) - get_global_time());
- return false;
- }
- }
- if (GetPoint(POINT_HORSE_SKILL) >= 20 ||
- GetSkillLevel(SKILL_HORSE_WILDATTACK) + GetSkillLevel(SKILL_HORSE_CHARGE) + GetSkillLevel(SKILL_HORSE_ESCAPE) >= 60 ||
- GetSkillLevel(SKILL_HORSE_WILDATTACK_RANGE) + GetSkillLevel(SKILL_HORSE_CHARGE) + GetSkillLevel(SKILL_HORSE_ESCAPE) >= 60)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti citi aceasta carte."));
- return false;
- }
- if (number(1, 100) <= iPct)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You understood the Reitanleitung..."));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You will receive a Reitpunkt."));
- PointChange(POINT_HORSE_SKILL, 1);
- int iReadDelay = number(SKILLBOOK_DELAY_MIN, SKILLBOOK_DELAY_MAX);
- if (distribution_test_server) iReadDelay /= 3;
- if (!test_server)
- SetSkillNextReadTime(dwSkillVnum, get_global_time() + iReadDelay);
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti intelege aceasta carte."));
- }
- item->SetCount(item->GetCount() - 1);
- }
- break;
- case 70102:
- case 70103:
- {
- if (GetAlignment() >= 0)
- return false;
- int delta = MIN(-GetAlignment(), item->GetValue(0));
- sys_log(0, "%s ALIGNMENT ITEM %d", GetName(), delta);
- UpdateAlignment(delta);
- item->SetCount(item->GetCount() - 1);
- if (delta / 10 > 0)
- {
- ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("Mintea ta a fost eliberata de spiritul rau."));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Gradul tau a urcat cu %d puncte."), delta/10);
- }
- }
- break;
- case 71107: // õµµº¹¼þ¾Æ
- {
- int val = item->GetValue(0);
- int interval = item->GetValue(1);
- quest::PC* pPC = quest::CQuestManager::instance().GetPC(GetPlayerID());
- int last_use_time = pPC->GetFlag("mythical_peach.last_use_time");
- if (get_global_time() - last_use_time < interval * 60 * 60)
- {
- if (test_server == false)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Trebuie sa mai astepti."));
- return false;
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Timpul de testare a trecut."));
- }
- }
- if (GetAlignment() == 200000)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[Fructul Vietii] Gradul tau este maxim."));
- return false;
- }
- if (200000 - GetAlignment() < val * 10)
- {
- val = (200000 - GetAlignment()) / 10;
- }
- int old_alignment = GetAlignment() / 10;
- UpdateAlignment(val*10);
- item->SetCount(item->GetCount()-1);
- pPC->SetFlag("mythical_peach.last_use_time", get_global_time());
- ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("Mintea ta a fost eliberata de spiritul rau."));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Balanta dintre Rau si Bine are un procentaj de %d."), val);
- char buf[256 + 1];
- snprintf(buf, sizeof(buf), "%d %d", old_alignment, GetAlignment() / 10);
- LogManager::instance().CharLog(this, val, "MYTHICAL_PEACH", buf);
- }
- break;
- case ITEM_NEW_YEAR_GREETING_VNUM:
- {
- DWORD dwBoxVnum = ITEM_NEW_YEAR_GREETING_VNUM;
- std::vector <DWORD> dwVnums;
- std::vector <DWORD> dwCounts;
- std::vector <LPITEM> item_gets;
- int count = 0;
- if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
- {
- for (int i = 0; i < count; i++)
- {
- if (dwVnums[i] == CSpecialItemGroup::GOLD)
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai primit nimic."), dwCounts[i]);
- }
- item->SetCount(item->GetCount() - 1);
- }
- }
- break;
- case ITEM_VALENTINE_ROSE:
- case ITEM_VALENTINE_CHOCOLATE:
- {
- DWORD dwBoxVnum = item->GetVnum();
- std::vector <DWORD> dwVnums;
- std::vector <DWORD> dwCounts;
- std::vector <LPITEM> item_gets(0);
- int count = 0;
- if (item->GetVnum() == ITEM_VALENTINE_ROSE && SEX_MALE==GET_SEX(this) ||
- item->GetVnum() == ITEM_VALENTINE_CHOCOLATE && SEX_FEMALE==GET_SEX(this))
- {
- // ¼ºº°ÀÌ ¸ÂÁö¾Ê¾Æ ¾µ ¼ö ¾ø´Ù.
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You have the wrong gender, you can not open the item."));
- return false;
- }
- if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
- item->SetCount(item->GetCount()-1);
- }
- break;
- case ITEM_WHITEDAY_CANDY:
- case ITEM_WHITEDAY_ROSE:
- {
- DWORD dwBoxVnum = item->GetVnum();
- std::vector <DWORD> dwVnums;
- std::vector <DWORD> dwCounts;
- std::vector <LPITEM> item_gets(NULL);
- int count = 0;
- if (item->GetVnum() == ITEM_WHITEDAY_CANDY && SEX_MALE==GET_SEX(this) ||
- item->GetVnum() == ITEM_WHITEDAY_ROSE && SEX_FEMALE==GET_SEX(this))
- {
- // 성별이 맞지않아 쓸 수 없다.
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest articol nu poate fi deschis deoarece sexul este incorect."));
- return false;
- }
- if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
- item->SetCount(item->GetCount()-1);
- }
- break;
- case 50011: // ¿ù±¤º¸ÇÕ
- {
- DWORD dwBoxVnum = 50011;
- std::vector <DWORD> dwVnums;
- std::vector <DWORD> dwCounts;
- std::vector <LPITEM> item_gets(0);
- int count = 0;
- if (GiveItemFromSpecialItemGroup(dwBoxVnum, dwVnums, dwCounts, item_gets, count))
- {
- for (int i = 0; i < count; i++)
- {
- char buf[50 + 1];
- snprintf(buf, sizeof(buf), "%u %u", dwVnums[i], dwCounts[i]);
- LogManager::instance().ItemLog(this, item, "MOONLIGHT_GET", buf);
- //item->SetCount(item->GetCount() - 1);
- item->SetCount(item->GetCount() - 1);
- switch (dwVnums[i])
- {
- case CSpecialItemGroup::GOLD:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai primit nimic."), dwCounts[i]);
- break;
- case CSpecialItemGroup::EXP:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ºÎÅÍ ½ÅºñÇÑ ºûÀÌ ³ª¿É´Ï´Ù."));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("%dÀÇ °æÇèÄ¡¸¦ ȹµæÇß½À´Ï´Ù."), dwCounts[i]);
- break;
- case CSpecialItemGroup::MOB:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ¸ó½ºÅͰ¡ ³ªÅ¸³µ½À´Ï´Ù!"));
- break;
- case CSpecialItemGroup::SLOW:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ³ª¿Â »¡°£ ¿¬±â¸¦ µéÀ̸¶½ÃÀÚ ¿òÁ÷ÀÌ´Â ¼Óµµ°¡ ´À·ÁÁ³½À´Ï´Ù!"));
- break;
- case CSpecialItemGroup::DRAIN_HP:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ°¡ °©ÀÚ±â Æø¹ßÇÏ¿´½À´Ï´Ù! »ý¸í·ÂÀÌ °¨¼ÒÇß½À´Ï´Ù."));
- break;
- case CSpecialItemGroup::POISON:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ³ª¿Â ³ì»ö ¿¬±â¸¦ µéÀ̸¶½ÃÀÚ µ¶ÀÌ ¿Â¸öÀ¸·Î ÆÛÁý´Ï´Ù!"));
- break;
- case CSpecialItemGroup::MOB_GROUP:
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("»óÀÚ¿¡¼ ¸ó½ºÅͰ¡ ³ªÅ¸³µ½À´Ï´Ù!"));
- break;
- default:
- if (item_gets[i])
- {
- if (dwCounts[i] > 1)
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s - %d x."), item_gets[i]->GetName(), dwCounts[i]);
- else
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s."), item_gets[i]->GetName());
- }
- break;
- }
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_TALKING, LC_TEXT("Nu ai primit nimic deoarece cufarul pare sa fie gol."));
- return false;
- }
- }
- break;
- case ITEM_GIVE_STAT_RESET_COUNT_VNUM:
- {
- //PointChange(POINT_GOLD, -iCost);
- PointChange(POINT_STAT_RESET_COUNT, 1);
- item->SetCount(item->GetCount()-1);
- }
- break;
- case 50107:
- {
- EffectPacket(SE_CHINA_FIREWORK);
- // ½ºÅÏ °ø°ÝÀ» ¿Ã·ÁÁØ´Ù
- AddAffect(AFFECT_CHINA_FIREWORK, POINT_STUN_PCT, 30, AFF_CHINA_FIREWORK, 5*60, 0, true);
- item->SetCount(item->GetCount()-1);
- }
- break;
- case 50108:
- {
- if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- return false;
- }
- EffectPacket(SE_SPIN_TOP);
- // ½ºÅÏ °ø°ÝÀ» ¿Ã·ÁÁØ´Ù
- AddAffect(AFFECT_CHINA_FIREWORK, POINT_STUN_PCT, 30, AFF_CHINA_FIREWORK, 5*60, 0, true);
- item->SetCount(item->GetCount()-1);
- }
- break;
- case ITEM_WONSO_BEAN_VNUM:
- PointChange(POINT_HP, GetMaxHP() - GetHP());
- item->SetCount(item->GetCount()-1);
- break;
- case ITEM_WONSO_SUGAR_VNUM:
- PointChange(POINT_SP, GetMaxSP() - GetSP());
- item->SetCount(item->GetCount()-1);
- break;
- case ITEM_WONSO_FRUIT_VNUM:
- PointChange(POINT_STAMINA, GetMaxStamina()-GetStamina());
- item->SetCount(item->GetCount()-1);
- break;
- case ITEM_ELK_VNUM:
- {
- int iGold = item->GetSocket(0);
- item->SetCount(item->GetCount() - 1);
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu ai primit nimic."), iGold);
- PointChange(POINT_GOLD, iGold);
- }
- break;
- #ifdef __BATTLE_PASS__
- case ITEM_BATTLE_PASS:
- {
- if (!v_counts.empty())
- {
- ChatPacket(CHAT_TYPE_INFO, "You have already one active!");
- return false;
- }
- FILE *fileID;
- char file_name[256+1];
- snprintf(file_name, sizeof(file_name), "%s/battlepass_players/%s.txt", LocaleService_GetBasePath().c_str(),GetName());
- fileID = fopen(file_name, "w");
- if (NULL == fileID)
- return false;
- for (int i=0; i<missions_bp.size(); ++i)
- {
- fprintf(fileID,"MISSION %d %d\n", 0, 0);
- }
- fclose(fileID);
- Load_BattlePass();
- ChatPacket(CHAT_TYPE_INFO, "You activate battle pass for this month!");
- item->SetCount(item->GetCount() - 1);
- }
- break;
- #endif
- case 70021:
- {
- int HealPrice = quest::CQuestManager::instance().GetEventFlag("MonarchHealGold");
- if (HealPrice == 0)
- HealPrice = 2000000;
- if (CMonarch::instance().HealMyEmpire(this, HealPrice))
- {
- char szNotice[256];
- snprintf(szNotice, sizeof(szNotice), LC_TEXT("The monarch spoke his blessing to %s and fills all the HP and SP."), EMPIRE_NAME(GetEmpire()));
- SendNoticeMap(szNotice, GetMapIndex(), false);
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Blessing of the RE used."));
- }
- }
- break;
- case 71092 :
- {
- if (m_pkChrTarget != NULL)
- {
- if (m_pkChrTarget->IsPolymorphed())
- {
- m_pkChrTarget->SetPolymorph(0);
- m_pkChrTarget->RemoveAffect(AFFECT_POLYMORPH);
- }
- }
- else
- {
- if (IsPolymorphed())
- {
- SetPolymorph(0);
- RemoveAffect(AFFECT_POLYMORPH);
- }
- }
- }
- break;
- case 71051 :
- {
- LPITEM item2;
- if (!IsValidItemPosition(DestCell) || !(item2 = GetInventoryItem(wDestCell)))
- return false;
- if (item2->IsExchanging() == true)
- return false;
- #ifdef BONUS_ON_EQUIPED_FIX
- if (item2->IsEquipped())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Nu poti adauga bonusuri obiectelor echipate!"));
- return false;
- }
- #endif
- //blocare bonus pe costume 6/7 dnd START
- #ifdef DISABLE_BONUS_67_COSTUME
- if (item2->GetType() == ITEM_COSTUME)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Nu poti atribuii bonusuri unui costum!"));
- return false;
- }
- #endif //blocare bonus pe costume 6/7 dnd END
- //blocare bonus ob speciale 6/7 dnd END
- if (item2->GetType() == ITEM_RING)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Nu poti atribuii bonusuri unui obiect special!"));
- return false;
- }
- if (item2->GetAttributeSetIndex() == -1)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Nu poti adauga mai multe bonusuri speciale!"));
- return false;
- }
- if (item2->AddRareAttribute() == true)
- {
- //ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Ai adaugat bonusul cu succes!"));
- int iAddedIdx = item2->GetRareAttrCount() + 4;
- char buf[21];
- snprintf(buf, sizeof(buf), "%u", item2->GetID());
- LogManager::instance().ItemLog(
- GetPlayerID(),
- item2->GetAttributeType(iAddedIdx),
- item2->GetAttributeValue(iAddedIdx),
- item->GetID(),
- "ADD_RARE_ATTR",
- buf,
- GetDesc()->GetHostName(),
- item->GetOriginalVnum());
- item->SetCount(item->GetCount() - 1);
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Nu poti adauga mai multe bonusuri speciale!"));
- }
- }
- break;
- case 71052 :
- {
- LPITEM item2;
- if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
- return false;
- if (item2->IsExchanging() == true)
- return false;
- #ifdef DISABLE_BONUS_67_COSTUME
- if (item2->GetType() == ITEM_COSTUME)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cant change 6/7 bonuses on costumes"));
- return false;
- }
- #endif
- if (item2->GetType() == ITEM_RING)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cant change 6/7 bonuses on special items"));
- return false;
- }
- if (item2->GetAttributeSetIndex() == -1)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga un bonus acestui item."));
- return false;
- }
- #ifdef BONUS_ON_EQUIPED_FIX
- if (item2->IsEquipped())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("[SYSTEM] Nu poti schimba bonusurile obiectelor echipate!"));
- return false;
- }
- #endif
- if (item2->ChangeRareAttribute() == true)
- {
- char buf[21];
- snprintf(buf, sizeof(buf), "%u", item2->GetID());
- LogManager::instance().ItemLog(this, item, "CHANGE_RARE_ATTR", buf);
- item->SetCount(item->GetCount() - 1);
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai schimbat bonusul cu succes."));
- }
- }
- break;
- case ITEM_AUTO_HP_RECOVERY_S:
- case ITEM_AUTO_HP_RECOVERY_M:
- case ITEM_AUTO_HP_RECOVERY_L:
- case ITEM_AUTO_HP_RECOVERY_X:
- case ITEM_AUTO_SP_RECOVERY_S:
- case ITEM_AUTO_SP_RECOVERY_M:
- case ITEM_AUTO_SP_RECOVERY_L:
- case ITEM_AUTO_SP_RECOVERY_X:
- // ¹«½Ã¹«½ÃÇÏÁö¸¸ ÀÌÀü¿¡ ÇÏ´ø °É °íÄ¡±â´Â ¹«¼·°í...
- // ±×·¡¼ ±×³É Çϵå ÄÚµù. ¼±¹° »óÀÚ¿ë ÀÚµ¿¹°¾à ¾ÆÀÌÅÛµé.
- case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_XS:
- case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_S:
- case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_XS:
- case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_S:
- case FUCKING_BRAZIL_ITEM_AUTO_SP_RECOVERY_S:
- case FUCKING_BRAZIL_ITEM_AUTO_HP_RECOVERY_S:
- if (FindAffect(AFFECT_ITEM_BLOCK))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Sistem> Trebuie sa astepti 5 secunde pentru a putea face asta!"));
- return false;
- }
- {
- if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- return false;
- }
- EAffectTypes type = AFFECT_NONE;
- bool isSpecialPotion = false;
- switch (item->GetVnum())
- {
- case ITEM_AUTO_HP_RECOVERY_X:
- isSpecialPotion = true;
- case ITEM_AUTO_HP_RECOVERY_S:
- case ITEM_AUTO_HP_RECOVERY_M:
- case ITEM_AUTO_HP_RECOVERY_L:
- case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_XS:
- case REWARD_BOX_ITEM_AUTO_HP_RECOVERY_S:
- case FUCKING_BRAZIL_ITEM_AUTO_HP_RECOVERY_S:
- type = AFFECT_AUTO_HP_RECOVERY;
- break;
- case ITEM_AUTO_SP_RECOVERY_X:
- isSpecialPotion = true;
- case ITEM_AUTO_SP_RECOVERY_S:
- case ITEM_AUTO_SP_RECOVERY_M:
- case ITEM_AUTO_SP_RECOVERY_L:
- case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_XS:
- case REWARD_BOX_ITEM_AUTO_SP_RECOVERY_S:
- case FUCKING_BRAZIL_ITEM_AUTO_SP_RECOVERY_S:
- type = AFFECT_AUTO_SP_RECOVERY;
- break;
- }
- if (AFFECT_NONE == type)
- break;
- if (item->GetCount() > 1)
- {
- int pos = GetEmptyInventory(item->GetSize());
- if (-1 == pos)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Item divided."));
- break;
- }
- item->SetCount( item->GetCount() - 1 );
- LPITEM item2 = ITEM_MANAGER::instance().CreateItem( item->GetVnum(), 1 );
- item2->AddToCharacter(this, TItemPos(INVENTORY, pos));
- if (item->GetSocket(1) != 0)
- {
- item2->SetSocket(1, item->GetSocket(1));
- }
- item = item2;
- }
- CAffect* pAffect = FindAffect( type );
- if (NULL == pAffect)
- {
- EPointTypes bonus = POINT_NONE;
- if (true == isSpecialPotion)
- {
- if (type == AFFECT_AUTO_HP_RECOVERY)
- {
- bonus = POINT_MAX_HP_PCT;
- }
- else if (type == AFFECT_AUTO_SP_RECOVERY)
- {
- bonus = POINT_MAX_SP_PCT;
- }
- }
- AddAffect( type, bonus, 4, item->GetID(), INFINITE_AFFECT_DURATION, 0, true, false);
- item->Lock(true);
- item->SetSocket(0, true);
- AutoRecoveryItemProcess( type );
- AddAffect(AFFECT_ITEM_BLOCK, POINT_NONE, 0, 0, 5, 0, true, false);
- }
- else
- {
- if (item->GetID() == pAffect->dwFlag)
- {
- RemoveAffect( pAffect );
- item->Lock(false);
- item->SetSocket(0, false);
- }
- else
- {
- LPITEM old = FindItemByID( pAffect->dwFlag );
- if (NULL != old)
- {
- old->Lock(false);
- old->SetSocket(0, false);
- }
- RemoveAffect( pAffect );
- EPointTypes bonus = POINT_NONE;
- if (true == isSpecialPotion)
- {
- if (type == AFFECT_AUTO_HP_RECOVERY)
- {
- bonus = POINT_MAX_HP_PCT;
- }
- else if (type == AFFECT_AUTO_SP_RECOVERY)
- {
- bonus = POINT_MAX_SP_PCT;
- }
- }
- AddAffect( type, bonus, 4, item->GetID(), INFINITE_AFFECT_DURATION, 0, true, false);
- item->Lock(true);
- item->SetSocket(0, true);
- AutoRecoveryItemProcess( type );
- }
- }
- }
- break;
- }
- break;
- case USE_CLEAR:
- {
- RemoveBadAffect();
- item->SetCount(item->GetCount() - 1);
- }
- break;
- case USE_POTION_NODELAY:
- {
- if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
- {
- if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit") > 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- return false;
- }
- switch (item->GetVnum())
- {
- case 70020 :
- case 71018 :
- case 71019 :
- case 71020 :
- if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit_count") < 10000)
- {
- if (m_nPotionLimit <= 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti folosi licori în arena luptelor. "));
- return false;
- }
- }
- break;
- default :
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- return false;
- }
- }
- bool used = false;
- if (item->GetValue(0) != 0) // HP
- {
- if (GetHP() < GetMaxHP())
- {
- PointChange(POINT_HP, item->GetValue(0) * (100 + GetPoint(POINT_POTION_BONUS)) / 100);
- EffectPacket(SE_HPUP_RED);
- used = TRUE;
- }
- }
- if (item->GetValue(1) != 0) // SP
- {
- if (GetSP() < GetMaxSP())
- {
- PointChange(POINT_SP, item->GetValue(1) * (100 + GetPoint(POINT_POTION_BONUS)) / 100);
- EffectPacket(SE_SPUP_BLUE);
- used = TRUE;
- }
- }
- if (item->GetValue(3) != 0) // HP %
- {
- if (GetHP() < GetMaxHP())
- {
- PointChange(POINT_HP, item->GetValue(3) * GetMaxHP() / 100);
- EffectPacket(SE_HPUP_RED);
- used = TRUE;
- }
- }
- if (item->GetValue(4) != 0) // SP %
- {
- if (GetSP() < GetMaxSP())
- {
- PointChange(POINT_SP, item->GetValue(4) * GetMaxSP() / 100);
- EffectPacket(SE_SPUP_BLUE);
- used = TRUE;
- }
- }
- if (used)
- {
- if (item->GetVnum() == 50085 || item->GetVnum() == 50086)
- {
- if (test_server)
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("All items were used"));
- SetUseSeedOrMoonBottleTime();
- }
- if (GetDungeon())
- GetDungeon()->UsePotion(this);
- if (GetWarMap())
- GetWarMap()->UsePotion(this, item);
- m_nPotionLimit--;
- //RESTRICT_USE_SEED_OR_MOONBOTTLE
- item->SetCount(item->GetCount() - 1);
- //END_RESTRICT_USE_SEED_OR_MOONBOTTLE
- }
- }
- break;
- case USE_POTION:
- if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
- {
- if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit") > 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- return false;
- }
- switch (item->GetVnum())
- {
- case 27001 :
- case 27002 :
- case 27003 :
- case 27004 :
- case 27005 :
- case 27006 :
- case 40489 :
- case 40490 :
- case 40491 :
- case 40492 :
- if (quest::CQuestManager::instance().GetEventFlag("arena_potion_limit_count") < 10000)
- {
- if (m_nPotionLimit <= 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti folosi licori în arena luptelor. "));
- return false;
- }
- }
- break;
- default :
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- return false;
- }
- }
- if (item->GetValue(1) != 0)
- {
- if (GetPoint(POINT_SP_RECOVERY) + GetSP() >= GetMaxSP())
- {
- return false;
- }
- PointChange(POINT_SP_RECOVERY, item->GetValue(1) * MIN(200, (100 + GetPoint(POINT_POTION_BONUS))) / 100);
- StartAffectEvent();
- EffectPacket(SE_SPUP_BLUE);
- }
- if (item->GetValue(0) != 0)
- {
- if (GetPoint(POINT_HP_RECOVERY) + GetHP() >= GetMaxHP())
- {
- return false;
- }
- PointChange(POINT_HP_RECOVERY, item->GetValue(0) * MIN(200, (100 + GetPoint(POINT_POTION_BONUS))) / 100);
- StartAffectEvent();
- EffectPacket(SE_HPUP_RED);
- }
- if (GetDungeon())
- GetDungeon()->UsePotion(this);
- if (GetWarMap())
- GetWarMap()->UsePotion(this, item);
- item->SetCount(item->GetCount() - 1);
- m_nPotionLimit--;
- break;
- case USE_POTION_CONTINUE:
- {
- if (item->GetValue(0) != 0)
- {
- AddAffect(AFFECT_HP_RECOVER_CONTINUE, POINT_HP_RECOVER_CONTINUE, item->GetValue(0), 0, item->GetValue(2), 0, true);
- }
- else if (item->GetValue(1) != 0)
- {
- AddAffect(AFFECT_SP_RECOVER_CONTINUE, POINT_SP_RECOVER_CONTINUE, item->GetValue(1), 0, item->GetValue(2), 0, true);
- }
- else
- return false;
- }
- if (GetDungeon())
- GetDungeon()->UsePotion(this);
- if (GetWarMap())
- GetWarMap()->UsePotion(this, item);
- item->SetCount(item->GetCount() - 1);
- break;
- case USE_ABILITY_UP:
- #ifdef ENABLE_YMIR_AFFECT_FIX
- if ((CheckTimeUsed(item) == false)) { return false; }
- #endif
- {
- switch (item->GetValue(0))
- {
- #ifdef ENABLE_DnD_AFFECT_FIX
- case APPLY_MOV_SPEED:
- if (FindAffect(AFFECT_MOV_SPEED))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<System> Folosesti deja un efect de viteza!"));
- return false;
- }
- AddAffect(AFFECT_MOV_SPEED, POINT_MOV_SPEED, item->GetValue(2), AFF_MOV_SPEED_POTION, item->GetValue(1), 0, true);
- EffectPacket(SE_DXUP_PURPLE); //purple potion
- break;
- #endif
- #ifdef ENABLE_DnD_AFFECT_FIX
- case APPLY_ATT_SPEED:
- if (FindAffect(AFFECT_ATT_SPEED))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<System> Folosesti deja un efect de viteza!"));
- return false;
- }
- AddAffect(AFFECT_ATT_SPEED, POINT_ATT_SPEED, item->GetValue(2), AFF_ATT_SPEED_POTION, item->GetValue(1), 0, true);
- EffectPacket(SE_SPEEDUP_GREEN); //green potion
- break;
- #endif
- case APPLY_STR:
- AddAffect(AFFECT_STR, POINT_ST, item->GetValue(2), 0, item->GetValue(1), 0, true);
- break;
- case APPLY_DEX:
- AddAffect(AFFECT_DEX, POINT_DX, item->GetValue(2), 0, item->GetValue(1), 0, true);
- break;
- case APPLY_CON:
- AddAffect(AFFECT_CON, POINT_HT, item->GetValue(2), 0, item->GetValue(1), 0, true);
- break;
- case APPLY_INT:
- AddAffect(AFFECT_INT, POINT_IQ, item->GetValue(2), 0, item->GetValue(1), 0, true);
- break;
- case APPLY_CAST_SPEED:
- AddAffect(AFFECT_CAST_SPEED, POINT_CASTING_SPEED, item->GetValue(2), 0, item->GetValue(1), 0, true);
- break;
- case APPLY_ATT_GRADE_BONUS:
- AddAffect(AFFECT_ATT_GRADE, POINT_ATT_GRADE_BONUS,
- item->GetValue(2), 0, item->GetValue(1), 0, true);
- break;
- case APPLY_DEF_GRADE_BONUS:
- AddAffect(AFFECT_DEF_GRADE, POINT_DEF_GRADE_BONUS,
- item->GetValue(2), 0, item->GetValue(1), 0, true);
- break;
- }
- }
- if (GetDungeon())
- GetDungeon()->UsePotion(this);
- if (GetWarMap())
- GetWarMap()->UsePotion(this, item);
- item->SetCount(item->GetCount() - 1);
- break;
- case USE_TALISMAN:
- {
- const int TOWN_PORTAL = 1;
- const int MEMORY_PORTAL = 2;
- // gm_guild_build, oxevent ¸Ê¿¡¼ ±ÍȯºÎ ±Íȯ±â¾ïºÎ ¸¦ »ç¿ë¸øÇÏ°Ô ¸·À½
- if (GetMapIndex() == 200 || GetMapIndex() == 113)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Disponibila in prezent."));
- return false;
- }
- if (CArenaManager::instance().IsArenaMap(GetMapIndex()) == true)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de data aceasta."));
- return false;
- }
- if (m_pkWarpEvent)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Te rog incearca mai tarziu"));
- return false;
- }
- // CONSUME_LIFE_WHEN_USE_WARP_ITEM
- int consumeLife = CalculateConsume(this);
- if (consumeLife < 0)
- return false;
- // END_OF_CONSUME_LIFE_WHEN_USE_WARP_ITEM
- if (item->GetValue(0) == TOWN_PORTAL)
- {
- if (item->GetSocket(0) == 0)
- {
- if (!GetDungeon())
- if (!GiveRecallItem(item))
- return false;
- PIXEL_POSITION posWarp;
- if (SECTREE_MANAGER::instance().GetRecallPositionByEmpire(GetMapIndex(), GetEmpire(), posWarp))
- {
- // CONSUME_LIFE_WHEN_USE_WARP_ITEM
- PointChange(POINT_HP, -consumeLife, false);
- // END_OF_CONSUME_LIFE_WHEN_USE_WARP_ITEM
- WarpSet(posWarp.x, posWarp.y);
- }
- else
- {
- sys_err("CHARACTER::UseItem : cannot find spawn position (name %s, %d x %d)", GetName(), GetX(), GetY());
- }
- }
- else
- {
- if (test_server)
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You will be teleported to the last position"));
- ProcessRecallItem(item);
- }
- }
- else if (item->GetValue(0) == MEMORY_PORTAL)
- {
- if (item->GetSocket(0) == 0)
- {
- if (GetDungeon())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti folosi %s%s"),
- item->GetName(),
- g_iUseLocale ? "" : (under_han(item->GetName()) ? LC_TEXT("de") : LC_TEXT("la")));
- return false;
- }
- if (!GiveRecallItem(item))
- return false;
- }
- else
- {
- // CONSUME_LIFE_WHEN_USE_WARP_ITEM
- PointChange(POINT_HP, -consumeLife, false);
- // END_OF_CONSUME_LIFE_WHEN_USE_WARP_ITEM
- ProcessRecallItem(item);
- }
- }
- }
- break;
- case USE_TUNING:
- case USE_DETACHMENT:
- {
- LPITEM item2;
- if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
- return false;
- if (item2->IsExchanging())
- return false;
- if (item2->IsEquipped())
- return false;
- #ifdef __SASH_SYSTEM__
- if (item->GetValue(0) == SASH_CLEAN_ATTR_VALUE0)
- {
- if (!CleanSashAttr(item, item2))
- return false;
- return true;
- }
- #endif
- if (item2->GetVnum() >= 28330 && item2->GetVnum() <= 28343) //+3
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("+3 ¿µ¼®Àº ÀÌ ¾ÆÀÌÅÛÀ¸·Î °³·®ÇÒ ¼ö ¾ø½À´Ï´Ù"));
- return false;
- }
- #ifdef STONE_ON_EQUIPED_FIX
- if (item2->IsEquipped())
- return false;
- #endif
- if (item2->GetVnum() >= 28430 && item2->GetVnum() <= 28443) // +4
- {
- if (item->GetVnum() == 71056)
- {
- RefineItem(item, item2);
- }
- #ifdef STONE_ON_EQUIPED_FIX
- if (item2->IsEquipped())
- return false;
- #endif
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Pietrele spirituale nu pot fi actualizate cu acest obiect."));
- }
- }
- else
- {
- RefineItem(item, item2);
- }
- }
- break;
- // ACCESSORY_REFINE & ADD/CHANGE_ATTRIBUTES
- case USE_PUT_INTO_BELT_SOCKET:
- case USE_PUT_INTO_RING_SOCKET:
- case USE_PUT_INTO_ACCESSORY_SOCKET:
- case USE_ADD_ACCESSORY_SOCKET:
- case USE_CLEAN_SOCKET:
- case USE_CHANGE_ATTRIBUTE:
- case USE_CHANGE_ATTRIBUTE2 :
- case USE_ADD_ATTRIBUTE:
- case USE_ADD_ATTRIBUTE2:
- {
- LPITEM item2;
- if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
- return false;
- if (item2->IsEquipped())
- {
- BuffOnAttr_RemoveBuffsFromItem(item2);
- }
- if (ITEM_COSTUME == item2->GetType())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi schimbat."));
- return false;
- }
- if (ITEM_RING == item2->GetType())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi schimbat."));
- return false;
- }
- if (item2->IsExchanging())
- return false;
- switch (item->GetSubType())
- {
- case USE_CLEAN_SOCKET:
- {
- int i;
- for (i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
- {
- if (item2->GetSocket(i) == ITEM_BROKEN_METIN_VNUM)
- break;
- }
- if (i == ITEM_SOCKET_MAX_NUM)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Spatiul nu este gasit."));
- return false;
- }
- int j = 0;
- for (i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
- {
- if (item2->GetSocket(i) != ITEM_BROKEN_METIN_VNUM && item2->GetSocket(i) != 0)
- item2->SetSocket(j++, item2->GetSocket(i));
- }
- for (; j < ITEM_SOCKET_MAX_NUM; ++j)
- {
- if (item2->GetSocket(j) > 0)
- item2->SetSocket(j, 1);
- }
- {
- char buf[21];
- snprintf(buf, sizeof(buf), "%u", item2->GetID());
- LogManager::instance().ItemLog(this, item, "CLEAN_SOCKET", buf);
- }
- item->SetCount(item->GetCount() - 1);
- }
- break;
- case USE_CHANGE_ATTRIBUTE :
- if (item2->GetAttributeSetIndex() == -1)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi schimbat."));
- return false;
- }
- if (item2->IsEquipped()){
- ChatPacket(CHAT_TYPE_INFO, "[SYSTEM] Nu poti schimba bonusurile obiectelor echipate!");
- return false;
- }
- if (item2->GetAttributeCount() == 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu exista proprietati de modificat."));
- return false;
- }
- if (GM_PLAYER == GetGMLevel() && false == test_server)
- {
- DWORD dwChangeItemAttrCycle = quest::CQuestManager::instance().GetEventFlag(msc_szChangeItemAttrCycleFlag);
- if (dwChangeItemAttrCycle < msc_dwDefaultChangeItemAttrCycle)
- dwChangeItemAttrCycle = msc_dwDefaultChangeItemAttrCycle;
- quest::PC* pPC = quest::CQuestManager::instance().GetPC(GetPlayerID());
- if (pPC)
- {
- DWORD dwNowMin = get_global_time() / 60;
- pPC->SetFlag(msc_szLastChangeItemAttrFlag, dwNowMin);
- }
- }
- if (item->GetSubType() == USE_CHANGE_ATTRIBUTE2)
- {
- int aiChangeProb[ITEM_ATTRIBUTE_MAX_LEVEL] =
- {
- 0, 0, 30, 40, 3
- };
- item2->ChangeAttribute(aiChangeProb);
- }
- else
- {
- if (item->GetVnum() == 71151 || item->GetVnum() == 76023)
- {
- if ((item2->GetType() == ITEM_WEAPON)
- || (item2->GetType() == ITEM_ARMOR && item2->GetSubType() == ARMOR_BODY))
- {
- bool bCanUse = true;
- for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
- {
- if (item2->GetLimitType(i) == LIMIT_LEVEL && item2->GetLimitValue(i) > 40)
- {
- bCanUse = false;
- break;
- }
- }
- if (false == bCanUse)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest item poate fi folosit doar pentru armele si armurile pana in level 40."));
- break;
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Disponibil doar pe arme si armuri."));
- break;
- }
- }
- item2->ChangeAttribute();
- }
- //ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Bonus schimbat..."));
- {
- char buf[21];
- snprintf(buf, sizeof(buf), "%u", item2->GetID());
- LogManager::instance().ItemLog(this, item, "CHANGE_ATTRIBUTE", buf);
- }
- item->SetCount(item->GetCount() - 1);
- break;
- case USE_ADD_ATTRIBUTE :
- if (item2->GetAttributeSetIndex() == -1)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi schimbat."));
- return false;
- }
- #ifdef BONUS_ON_EQUIPED_FIX
- if (item2->IsEquipped())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can`t change attributes when item is equipped!");
- return false;
- }
- #endif
- if (item2->GetAttributeCount() < 4)
- {
- if (item->GetVnum() == 71152 || item->GetVnum() == 76024)
- {
- if ((item2->GetType() == ITEM_WEAPON)
- || (item2->GetType() == ITEM_ARMOR && item2->GetSubType() == ARMOR_BODY))
- {
- bool bCanUse = true;
- for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
- {
- if (item2->GetLimitType(i) == LIMIT_LEVEL && item2->GetLimitValue(i) > 40)
- {
- bCanUse = false;
- break;
- }
- }
- if (false == bCanUse)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest item poate fi folosit doar pentru armele si armurile pana in level 40."));
- break;
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Disponibil doar pe arme si armuri."));
- break;
- }
- }
- char buf[21];
- snprintf(buf, sizeof(buf), "%u", item2->GetID());
- if (number(1, 100) <= aiItemAttributeAddPercent[item2->GetAttributeCount()])
- {
- item2->AddAttribute();
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Bonusul a fost adaugat cu succes."));
- int iAddedIdx = item2->GetAttributeCount() - 1;
- LogManager::instance().ItemLog(
- GetPlayerID(),
- item2->GetAttributeType(iAddedIdx),
- item2->GetAttributeValue(iAddedIdx),
- item->GetID(),
- "ADD_ATTRIBUTE_SUCCESS",
- buf,
- GetDesc()->GetHostName(),
- item->GetOriginalVnum());
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Bonusul a esuat la adaugare."));
- LogManager::instance().ItemLog(this, item, "ADD_ATTRIBUTE_FAIL", buf);
- }
- item->SetCount(item->GetCount() - 1);
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga bonus."));
- }
- break;
- case USE_ADD_ATTRIBUTE2 :
- if (item2->GetAttributeSetIndex() == -1)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi schimbat."));
- return false;
- }
- if (item2->GetType() == ARMOR_PENDANT)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi schimbat."));
- return false;
- }
- if (item2->GetAttributeCount() == 4)
- {
- char buf[21];
- snprintf(buf, sizeof(buf), "%u", item2->GetID());
- if (number(1, 100) <= aiItemAttributeAddPercent[item2->GetAttributeCount()])
- {
- item2->AddAttribute();
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Bonusul a esuat la adaugare."));
- int iAddedIdx = item2->GetAttributeCount() - 1;
- LogManager::instance().ItemLog(
- GetPlayerID(),
- item2->GetAttributeType(iAddedIdx),
- item2->GetAttributeValue(iAddedIdx),
- item->GetID(),
- "ADD_ATTRIBUTE2_SUCCESS",
- buf,
- GetDesc()->GetHostName(),
- item->GetOriginalVnum());
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Bonusul a esuat la adaugare."));
- LogManager::instance().ItemLog(this, item, "ADD_ATTRIBUTE2_FAIL", buf);
- }
- item->SetCount(item->GetCount() - 1);
- }
- else if (item2->GetAttributeCount() == 5)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga alte bonusuri."));
- }
- else if (item2->GetAttributeCount() < 4)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti folosi asa ceva."));
- }
- else
- {
- // wtf ?!
- sys_err("ADD_ATTRIBUTE2 : Item has wrong AttributeCount(%d)", item2->GetAttributeCount());
- }
- break;
- case USE_ADD_ACCESSORY_SOCKET:
- {
- char buf[21];
- snprintf(buf, sizeof(buf), "%u", item2->GetID());
- if (item2->IsAccessoryForSocket())
- {
- if (item2->GetAccessorySocketMaxGrade() < ITEM_ACCESSORY_SOCKET_MAX_NUM)
- {
- if (number(1, 100) <= 50)
- {
- item2->SetAccessorySocketMaxGrade(item2->GetAccessorySocketMaxGrade() + 1);
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Adaugarea diamantului a reusit."));
- LogManager::instance().ItemLog(this, item, "ADD_SOCKET_SUCCESS", buf);
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Adaugarea diamantului a esuat."));
- LogManager::instance().ItemLog(this, item, "ADD_SOCKET_FAIL", buf);
- }
- item->SetCount(item->GetCount() - 1);
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu mai exista sloturi disponibile pe acest item."));
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti citi aceasta carte !."));
- }
- }
- break;
- case USE_PUT_INTO_BELT_SOCKET:
- case USE_PUT_INTO_ACCESSORY_SOCKET:
- if (item2->IsAccessoryForSocket() && item->CanPutInto(item2))
- {
- char buf[21];
- snprintf(buf, sizeof(buf), "%u", item2->GetID());
- if (item2->GetAccessorySocketGrade() < item2->GetAccessorySocketMaxGrade())
- {
- if (number(1, 100) <= aiAccessorySocketPutPct[item2->GetAccessorySocketGrade()])
- {
- item2->SetAccessorySocketGrade(item2->GetAccessorySocketGrade() + 1);
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Adaugare reusita."));
- LogManager::instance().ItemLog(this, item, "PUT_SOCKET_SUCCESS", buf);
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Adaugare esuata."));
- LogManager::instance().ItemLog(this, item, "PUT_SOCKET_FAIL", buf);
- }
- item->SetCount(item->GetCount() - 1);
- }
- else
- {
- if (item2->GetAccessorySocketMaxGrade() == 0)
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai adaugat un diamant."));
- else if (item2->GetAccessorySocketMaxGrade() < ITEM_ACCESSORY_SOCKET_MAX_NUM)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("In this object there are no other slots for stones."));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai adaugat diamantul cu succes."));
- }
- else
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Exorcism role Enabled"));
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asa ceva."));
- }
- break;
- }
- if (item2->IsEquipped())
- {
- BuffOnAttr_AddBuffsFromItem(item2);
- }
- }
- break;
- // END_OF_ACCESSORY_REFINE & END_OF_ADD_ATTRIBUTES & END_OF_CHANGE_ATTRIBUTES
- case USE_BAIT:
- {
- if (m_pkFishingEvent)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can not change bait!"));
- return false;
- }
- LPITEM weapon = GetWear(WEAR_WEAPON);
- if (!weapon || weapon->GetType() != ITEM_ROD)
- return false;
- if (weapon->GetSocket(2))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai schimbat momeala."), item->GetName());
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Folosesti ca momeala: %s"), item->GetName());
- }
- weapon->SetSocket(2, item->GetValue(0));
- item->SetCount(item->GetCount() - 1);
- }
- break;
- case USE_MOVE:
- case USE_TREASURE_BOX:
- case USE_MONEYBAG:
- break;
- #ifdef ENABLE_AFFECT_ITEMS_PLUS
- case USE_AFFECT :
- {
- int affect_type = item->GetValue(0);
- int apply_type = aApplyInfo[item->GetValue(1)].bPointType;
- int apply_value = item->GetValue(2);
- int affect_state_socket = 0;
- CAffect* pAffect = FindAffect(affect_type, apply_type);
- if (pAffect == NULL)
- {
- AddAffect(affect_type, apply_type, apply_value, item->GetID(), INFINITE_AFFECT_DURATION, 0, false);
- item->SetSocket(affect_state_socket, 1);
- item->Lock(true);
- }
- else
- {
- if (item->GetID() == pAffect->dwFlag)
- {
- RemoveAffect( pAffect );
- item->Lock(false);
- item->SetSocket(affect_state_socket, 0);
- }
- else
- {
- LPITEM old = FindItemByID( pAffect->dwFlag );
- if (NULL != old)
- {
- old->Lock(false);
- old->SetSocket(affect_state_socket, 0);
- }
- RemoveAffect(pAffect);
- AddAffect(affect_type, apply_type, apply_value, item->GetID(), INFINITE_AFFECT_DURATION, 0, false);
- item->SetSocket(affect_state_socket, 1);
- item->Lock(true);
- }
- }
- }
- break;
- #else
- case USE_AFFECT :
- {
- if (FindAffect(item->GetValue(0), aApplyInfo[item->GetValue(1)].bPointType))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Deja Functioneaza."));
- }
- else
- {
- // PC_BANG_ITEM_ADD
- if (item->IsPCBangItem() == true)
- {
- // PC¹æÀÎÁö Ã¼Å©ÇØ¼ ó¸®
- if (CPCBangManager::instance().IsPCBangIP(GetDesc()->GetHostName()) == false)
- {
- // PC¹æÀÌ ¾Æ´Ô!
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("This book can be found at low levels of metin."));
- return false;
- }
- }
- // END_PC_BANG_ITEM_ADD
- AddAffect(item->GetValue(0), aApplyInfo[item->GetValue(1)].bPointType, item->GetValue(2), 0, item->GetValue(3), 0, false);
- item->SetCount(item->GetCount() - 1);
- }
- }
- break;
- #endif
- case USE_CREATE_STONE:
- AutoGiveItem(number(28000, 28013));
- item->SetCount(item->GetCount() - 1);
- break;
- }
- }
- break;
- case ITEM_METIN:
- {
- LPITEM item2;
- if (!IsValidItemPosition(DestCell) || !(item2 = GetItem(DestCell)))
- return false;
- if (item2->IsExchanging())
- return false;
- if (item2->GetType() == ITEM_PICK) return false;
- if (item2->GetType() == ITEM_ROD) return false;
- int i;
- for (i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
- {
- DWORD dwVnum;
- if ((dwVnum = item2->GetSocket(i)) <= 2)
- continue;
- TItemTable * p = ITEM_MANAGER::instance().GetTable(dwVnum);
- if (!p)
- continue;
- if (item->GetValue(5) == p->alValues[5])
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga mai multe pietre de aceelasi fel."));
- return false;
- }
- }
- if (item2->GetType() == ITEM_ARMOR)
- {
- if (!IS_SET(item->GetWearFlag(), WEARABLE_BODY) || !IS_SET(item2->GetWearFlag(), WEARABLE_BODY))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Exista deja pietre."));
- return false;
- }
- }
- else if (item2->GetType() == ITEM_WEAPON)
- {
- if (!IS_SET(item->GetWearFlag(), WEARABLE_WEAPON))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Only you can put 2 stones in war."));
- return false;
- }
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu se poate adauga pe acest slot."));
- return false;
- }
- for (i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
- if (item2->GetSocket(i) >= 1 && item2->GetSocket(i) <= 2 && item2->GetSocket(i) >= item->GetValue(2))
- {
- if (number(1, 100) <= 30)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Piatra a fost adaugata cu succes!"));
- item2->SetSocket(i, item->GetVnum());
- }
- else
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Piatra nu a fost adaugata."));
- item2->SetSocket(i, ITEM_BROKEN_METIN_VNUM);
- }
- LogManager::instance().ItemLog(this, item2, "SOCKET", item->GetName());
- item->SetCount(item->GetCount() - 1);
- break;
- }
- if (i == ITEM_SOCKET_MAX_NUM)
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu se poate adauga pe acest slot."));
- }
- break;
- case ITEM_AUTOUSE:
- case ITEM_MATERIAL:
- case ITEM_SPECIAL:
- case ITEM_TOOL:
- case ITEM_LOTTERY:
- break;
- case ITEM_TOTEM:
- {
- if (!item->IsEquipped())
- EquipItem(item);
- }
- break;
- #ifdef ENABLE_DEWS_PLUS
- case ITEM_BLEND:
- #ifdef ENABLE_YMIR_AFFECT_FIX
- if ((CheckTimeUsed(item) == false)) { return false; }
- #endif
- sys_log(0,"ITEM_BLEND!!");
- if (Blend_Item_find(item->GetVnum()))
- {
- int affect_type = AFFECT_BLEND;
- if (item->GetSocket(0) >= (int)_countof(aApplyInfo))
- {
- sys_err ("INVALID BLEND ITEM(id : %d, vnum : %d). APPLY TYPE IS %d.", item->GetID(), item->GetVnum(), item->GetSocket(0));
- return false;
- }
- int apply_type = aApplyInfo[item->GetSocket(0)].bPointType;
- int apply_value = item->GetSocket(1);
- CAffect* pAffect = FindAffect(affect_type, apply_type);
- item->SetSocket(2, 0);
- if (pAffect == NULL)
- {
- AddAffect(affect_type, apply_type, apply_value, item->GetID(), INFINITE_AFFECT_DURATION, 0, false);
- item->SetSocket(2, 1);
- item->Lock(true);
- #ifdef ENABLE_NEW_AFFECT_POTION
- SetAffectPotion(item);
- #endif
- }
- else
- {
- if (item->GetID() == pAffect->dwFlag)
- {
- RemoveAffect( pAffect );
- item->Lock(false);
- item->SetSocket(2, 0);
- #ifdef ENABLE_NEW_AFFECT_POTION
- RemoveAffectPotion(item);
- #endif
- }
- else
- {
- LPITEM old = FindItemByID( pAffect->dwFlag );
- if (NULL != old)
- {
- old->Lock(false);
- old->SetSocket(2, 0);
- }
- RemoveAffect(pAffect);
- #ifdef ENABLE_NEW_AFFECT_POTION
- RemoveAffectPotion(item);
- #endif
- AddAffect(affect_type, apply_type, apply_value, item->GetID(), INFINITE_AFFECT_DURATION, 0, false);
- item->SetSocket(2, 1);
- item->Lock(true);
- #ifdef ENABLE_NEW_AFFECT_POTION
- SetAffectPotion(item);
- #endif
- }
- }
- }
- break;
- #else
- case ITEM_BLEND:
- sys_log(0,"ITEM_BLEND!!");
- if (Blend_Item_find(item->GetVnum()))
- {
- int affect_type = AFFECT_BLEND;
- int apply_type = aApplyInfo[item->GetSocket(0)].bPointType;
- int apply_value = item->GetSocket(1);
- int apply_duration = item->GetSocket(2);
- if (FindAffect(affect_type, apply_type))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Folosesti efectul!"));
- }
- else
- {
- if (FindAffect(AFFECT_EXP_BONUS_EURO_FREE, POINT_RESIST_MAGIC))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Folosesti efectul!"));
- }
- else
- {
- AddAffect(affect_type, apply_type, apply_value, 0, apply_duration, 0, false);
- #ifdef ENABLE_NEW_AFFECT_POTION
- SetAffectPotion(item);
- #endif
- item->SetCount(item->GetCount() - 1);
- }
- }
- }
- break;
- #endif
- case ITEM_EXTRACT:
- {
- LPITEM pDestItem = GetItem(DestCell);
- if (NULL == pDestItem)
- {
- return false;
- }
- switch (item->GetSubType())
- {
- case EXTRACT_DRAGON_SOUL:
- if (pDestItem->IsDragonSoul())
- {
- return DSManager::instance().PullOut(this, NPOS, pDestItem, item);
- }
- return false;
- case EXTRACT_DRAGON_HEART:
- if (pDestItem->IsDragonSoul())
- {
- return DSManager::instance().ExtractDragonHeart(this, pDestItem, item);
- }
- return false;
- default:
- return false;
- }
- }
- break;
- case ITEM_NONE:
- sys_err("Item type NONE %s", item->GetName());
- break;
- default:
- sys_log(0, "UseItemEx: Unknown type %s %d", item->GetName(), item->GetType());
- return false;
- }
- return true;
- }
- int g_nPortalLimitTime = 10;
- bool CHARACTER::UseItem(TItemPos Cell, TItemPos DestCell)
- {
- WORD wCell = Cell.cell;
- BYTE window_type = Cell.window_type;
- WORD wDestCell = DestCell.cell;
- BYTE bDestInven = DestCell.window_type;
- LPITEM item;
- if (!CanHandleItem())
- return false;
- if (!IsValidItemPosition(Cell) || !(item = GetItem(Cell)))
- return false;
- if (item->GetVnum() == 50570) // change with your item vnum
- {
- BiologManager::instance().RestartTime(this);
- item->SetCount(item->GetCount() - 1);
- }
- sys_log(0, "%s: USE_ITEM %s (inven %d, cell: %d)", GetName(), item->GetName(), window_type, wCell);
- #ifdef __BIOLOG_TIME__
- if (item->GetVnum() == 30219)
- {
- BiologManager::instance().RestartTime(this);
- item->SetCount(item->GetCount() - 1);
- }
- #endif
- if (item->IsExchanging())
- return false;
- #ifdef __ATTR_SWITCH_SYSTEM__
- if (Cell.IsSwitchbotPosition())
- {
- CSwitchbot* pkSwitchbot = CSwitchbotManager::Instance().FindSwitchbot(GetPlayerID());
- if (pkSwitchbot && pkSwitchbot->IsActive(Cell.cell))
- return false;
- int iEmptyCell = GetEmptyInventory(item->GetSize());
- if (iEmptyCell == -1)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Cannot remove item from switchbot. Inventory is full."));
- return false;
- }
- MoveItem(Cell, TItemPos(INVENTORY, iEmptyCell), item->GetCount());
- return true;
- }
- #endif
- if (!item->CanUsedBy(this))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu puteti purta asa ceva!"));
- return false;
- }
- if (IsStun())
- return false;
- if (false == FN_check_item_sex(this, item))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi purtat de sexul dumneavoastra."));
- return false;
- }
- #ifdef BLOCK_ITEM_IN_MAP
- if (IS_ENABLE_ITEM(item->GetVnum()))
- {
- if (false == IS_ENABLE_ITEM_ZONE(GetMapIndex()))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti folosii obiectul in aceasta mapa"));
- return false;
- }
- }
- #endif
- //PREVENT_TRADE_WINDOW
- if (IS_SUMMON_ITEM(item->GetVnum()))
- {
- if (false == IS_SUMMONABLE_ZONE(GetMapIndex()))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu se poate folosi un pergament in acest loc."));
- return false;
- }
- if (CThreeWayWar::instance().IsThreeWayWarMapIndex(GetMapIndex()))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu uita, in batalii nu poti folosii potiuni speciale."));
- return false;
- }
- int iPulse = thecore_pulse();
- if (iPulse - GetSafeboxLoadTime() < PASSES_PER_SEC(g_nPortalLimitTime))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti folosi aceasta aptitudine incã ."), g_nPortalLimitTime);
- if (test_server)
- ChatPacket(CHAT_TYPE_INFO, "[TestOnly]Pulse %d LoadTime %d PASS %d", iPulse, GetSafeboxLoadTime(), PASSES_PER_SEC(g_nPortalLimitTime));
- return false;
- }
- //PREVENT_REFINE_HACK
- {
- if (iPulse - GetRefineTime() < PASSES_PER_SEC(g_nPortalLimitTime))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Trebuie sa astepti %d"), g_nPortalLimitTime);
- return false;
- }
- }
- //END_PREVENT_REFINE_HACK
- //PREVENT_ITEM_COPY
- {
- if (iPulse - GetMyShopTime() < PASSES_PER_SEC(g_nPortalLimitTime))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Trebuie sa astepti %d secunde"), g_nPortalLimitTime);
- return false;
- }
- }
- //END_PREVENT_ITEM_COPY
- if (item->GetVnum() != 70302)
- {
- PIXEL_POSITION posWarp;
- int x = 0;
- int y = 0;
- double nDist = 0;
- const double nDistant = 5000.0;
- if (item->GetVnum() == 22010)
- {
- x = item->GetSocket(0) - GetX();
- y = item->GetSocket(1) - GetY();
- }
- else if (item->GetVnum() == 22000)
- {
- SECTREE_MANAGER::instance().GetRecallPositionByEmpire(GetMapIndex(), GetEmpire(), posWarp);
- if (item->GetSocket(0) == 0)
- {
- x = posWarp.x - GetX();
- y = posWarp.y - GetY();
- }
- else
- {
- x = item->GetSocket(0) - GetX();
- y = item->GetSocket(1) - GetY();
- }
- }
- nDist = sqrt(pow((float)x,2) + pow((float)y,2));
- if (nDistant > nDist)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu te poti teleporta in acest loc."));
- if (test_server)
- ChatPacket(CHAT_TYPE_INFO, "PossibleDistant %f nNowDist %f", nDistant,nDist);
- return false;
- }
- }
- //PREVENT_PORTAL_AFTER_EXCHANGE
- if (iPulse - GetExchangeTime() < PASSES_PER_SEC(g_nPortalLimitTime))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Trebuie sa astepti %d secunde"), g_nPortalLimitTime);
- return false;
- }
- //END_PREVENT_PORTAL_AFTER_EXCHANGE
- }
- if (item->GetVnum() == 50200 | item->GetVnum() == 71049)
- {
- if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti deschide magain in timp ce ai alte ferestre deschise sau esti transformat."));
- return false;
- }
- }
- #ifdef ITEM_BUFF_SYSTEM
- if (item->GetVnum() == MASTER_RESIST_BLESS_ITEM_BUFF_VNUM)
- {
- if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
- return false;
- }
- if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
- {
- ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
- return false;
- }
- if (true == IsDead())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
- return false;
- }
- else
- {
- if (FindAffect(SKILL_RESIST_BUFF))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Resistance Buff, [Item Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- if (IsAffectFlag(AFF_HOSIN))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Resistance Buff, [Shaman Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- {
- item->SetSocket(0, item->GetSocket(0) + 1);
- AddAffect(SKILL_RESIST_BUFF, POINT_RESIST_NORMAL_DAMAGE, MASTER_RESIST_BLESS_AFFECT_VALUE, AFF_RESIST_BUFF, MASTER_RESIST_BLESS_AFFECT_TIME_VALUE, 0, true, true);
- if (item->GetSocket(0) >= MASTER_RESIST_BLESS_USINGS)
- {
- ITEM_MANAGER::instance().RemoveItem(item);
- }
- ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Resistance Buff , [Item Buff] for 160 seconds.");
- ChatPacket(CHAT_TYPE_INFO, "Buff resist rate applied: 24%.");
- }
- }
- }
- if (item->GetVnum() == GRAND_RESIST_BLESS_ITEM_BUFF_VNUM) //
- {
- if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
- return false;
- }
- if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
- {
- ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
- return false;
- }
- if (true == IsDead())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
- return false;
- }
- else
- {
- if (FindAffect(SKILL_RESIST_BUFF))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Resistance Buff, [Item Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- if (IsAffectFlag(AFF_HOSIN))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Resistance Buff, [Shaman Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- {
- item->SetSocket(0, item->GetSocket(0) + 1);
- AddAffect(SKILL_RESIST_BUFF, POINT_RESIST_NORMAL_DAMAGE, GRAND_RESIST_BLESS_AFFECT_VALUE, AFF_RESIST_BUFF, GRAND_RESIST_BLESS_AFFECT_TIME_VALUE, 0, true, true);
- if (item->GetSocket(0) >= GRAND_RESIST_BLESS_USINGS)
- {
- ITEM_MANAGER::instance().RemoveItem(item);
- }
- ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Resistance Buff , [Item Buff] for 224 seconds.");
- ChatPacket(CHAT_TYPE_INFO, "Buff resist rate applied: 29%.");
- }
- }
- }
- if (item->GetVnum() == PERFECT_RESIST_BLESS_ITEM_BUFF_VNUM) //
- {
- if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
- return false;
- }
- if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
- {
- ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
- return false;
- }
- if (true == IsDead())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
- return false;
- }
- else
- {
- if (FindAffect(SKILL_RESIST_BUFF))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Resistance Buff, [Item Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- if (IsAffectFlag(AFF_HOSIN))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Resistance Buff, [Shaman Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- {
- item->SetSocket(0, item->GetSocket(0) + 1);
- AddAffect(SKILL_RESIST_BUFF, POINT_RESIST_NORMAL_DAMAGE, PERFECT_RESIST_BLESS_AFFECT_VALUE, AFF_RESIST_BUFF, PERFECT_RESIST_BLESS_AFFECT_TIME_VALUE, 0, true, true);
- if (item->GetSocket(0) >= PERFECT_RESIST_BLESS_USINGS)
- {
- ITEM_MANAGER::instance().RemoveItem(item);
- }
- ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Resistance Buff, [Item Buff] for 310 seconds.");
- ChatPacket(CHAT_TYPE_INFO, "Buff resist rate applied: 35%.");
- }
- }
- }
- if (item->GetVnum() == MASTER_CRITICAL_BLESS_ITEM_BUFF_VNUM)
- {
- if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
- return false;
- }
- if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
- {
- ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
- return false;
- }
- if (true == IsDead())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
- return false;
- }
- else
- {
- if (FindAffect(SKILL_CRITICAL_BUFF))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff), [Item Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- if (IsAffectFlag(AFF_GICHEON))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff), [Shaman Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- {
- item->SetSocket(0, item->GetSocket(0) + 1);
- AddAffect(SKILL_CRITICAL_BUFF, POINT_CRITICAL_PCT, MASTER_CRITICAL_BLESS_AFFECT_VALUE, AFF_CRITICAL_BUFF, MASTER_CRITICAL_BLESS_AFFECT_TIME_VALUE, 0, true, true);
- if (item->GetSocket(0) >= MASTER_CRITICAL_BLESS_USINGS)
- {
- ITEM_MANAGER::instance().RemoveItem(item);
- }
- ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Dragon's Strength(Critical Buff), [Item Buff] for 110 seconds.");
- ChatPacket(CHAT_TYPE_INFO, "Buff critical rate applied: 24%.");
- }
- }
- }
- if (item->GetVnum() == GRAND_CRITICAL_BLESS_ITEM_BUFF_VNUM) //
- {
- if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
- return false;
- }
- if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
- {
- ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
- return false;
- }
- if (true == IsDead())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
- return false;
- }
- else
- {
- if (FindAffect(SKILL_CRITICAL_BUFF))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff), [Item Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- if (IsAffectFlag(AFF_GICHEON))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff), [Shaman Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- {
- item->SetSocket(0, item->GetSocket(0) + 1);
- AddAffect(SKILL_CRITICAL_BUFF, POINT_CRITICAL_PCT, GRAND_CRITICAL_BLESS_AFFECT_VALUE, AFF_CRITICAL_BUFF, GRAND_CRITICAL_BLESS_AFFECT_TIME_VALUE, 0, true, true);
- if (item->GetSocket(0) >= GRAND_CRITICAL_BLESS_USINGS)
- {
- ITEM_MANAGER::instance().RemoveItem(item);
- }
- ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Dragon's Strength(Critical Buff), [Item Buff] for 142 seconds.");
- ChatPacket(CHAT_TYPE_INFO, "Buff critical rate applied: 29%.");
- }
- }
- }
- if (item->GetVnum() == PERFECT_CRITICAL_BLESS_ITEM_BUFF_VNUM) //
- {
- if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
- return false;
- }
- if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
- {
- ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
- return false;
- }
- if (true == IsDead())
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff)!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- else
- {
- if (FindAffect(SKILL_CRITICAL_BUFF))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff), [Item Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- if (IsAffectFlag(AFF_GICHEON))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Dragon's Strength(Critical Buff), [Shaman Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- {
- item->SetSocket(0, item->GetSocket(0) + 1);
- AddAffect(SKILL_CRITICAL_BUFF, POINT_CRITICAL_PCT, PERFECT_CRITICAL_BLESS_AFFECT_VALUE, AFF_CRITICAL_BUFF, PERFECT_CRITICAL_BLESS_AFFECT_TIME_VALUE, 0, true, true);
- if (item->GetSocket(0) >= PERFECT_CRITICAL_BLESS_USINGS)
- {
- ITEM_MANAGER::instance().RemoveItem(item);
- }
- ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Dragon's Strength(Critical Buff), [Item Buff] for 185 seconds.");
- ChatPacket(CHAT_TYPE_INFO, "Buff critical rate applied: 35%.");
- }
- }
- }
- if (item->GetVnum() == MASTER_REFLECT_BLESS_ITEM_BUFF_VNUM)
- {
- if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
- return false;
- }
- if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
- {
- ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
- return false;
- }
- if (true == IsDead())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
- return false;
- }
- else
- {
- if (FindAffect(SKILL_REFLECT_BUFF))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Reflection, [Item Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- if (IsAffectFlag(AFF_BOHO))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Reflection, [Shaman Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- {
- item->SetSocket(0, item->GetSocket(0) + 1);
- AddAffect(SKILL_REFLECT_BUFF, POINT_REFLECT_MELEE, MASTER_REFLECT_BLESS_AFFECT_VALUE, AFF_REFLECT_BUFF, MASTER_REFLECT_BLESS_AFFECT_TIME_VALUE, 0, true, true);
- if (item->GetSocket(0) >= MASTER_REFLECT_BLESS_USINGS)
- {
- ITEM_MANAGER::instance().RemoveItem(item);
- }
- ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Reflection, [Item Buff] for 160 seconds.");
- ChatPacket(CHAT_TYPE_INFO, "Buff reflection rate applied: 21%.");
- }
- }
- }
- if (item->GetVnum() == GRAND_REFLECT_BLESS_ITEM_BUFF_VNUM) //
- {
- if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
- return false;
- }
- if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
- {
- ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
- return false;
- }
- if (true == IsDead())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
- return false;
- }
- else
- {
- if (FindAffect(SKILL_REFLECT_BUFF))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Reflection, [Item Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- if (IsAffectFlag(AFF_BOHO))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Reflection, [Shaman Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- {
- item->SetSocket(0, item->GetSocket(0) + 1);
- AddAffect(SKILL_REFLECT_BUFF, POINT_REFLECT_MELEE, GRAND_REFLECT_BLESS_AFFECT_VALUE, AFF_REFLECT_BUFF, GRAND_REFLECT_BLESS_AFFECT_TIME_VALUE, 0, true, true);
- if (item->GetSocket(0) >= GRAND_REFLECT_BLESS_USINGS)
- {
- ITEM_MANAGER::instance().RemoveItem(item);
- }
- ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Reflection, [Item Buff] for 224 seconds.");
- ChatPacket(CHAT_TYPE_INFO, "Buff reflection rate applied: 31%.");
- }
- }
- }
- if (item->GetVnum() == PERFECT_REFLECT_BLESS_ITEM_BUFF_VNUM) //
- {
- if (GetExchange() || GetMyShop() || GetShopOwner() || IsOpenSafebox() || IsCubeOpen())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you have exchange,safebox,refine or other windows opened!");
- return false;
- }
- if (GetMapIndex() == 1 || GetMapIndex() == 3 || GetMapIndex() == 21 || GetMapIndex() == 23 || GetMapIndex() == 41 || GetMapIndex() == 43 || GetMapIndex() == 113)
- {
- ChatPacket(CHAT_TYPE_INFO, "Nu poti folosii buff in aceasta mapa!");
- return false;
- }
- if (true == IsDead())
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't use buff items while you're dead!");
- return false;
- }
- else
- {
- if (FindAffect(SKILL_REFLECT_BUFF))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Reflection, [Item Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- if (IsAffectFlag(AFF_BOHO))
- {
- ChatPacket(CHAT_TYPE_INFO, "You're already blessed with: Reflection, [Shaman Buff]!");
- ChatPacket(CHAT_TYPE_INFO, "Wait for your current buff to disappear and try again!");
- return false;
- }
- {
- item->SetSocket(0, item->GetSocket(0) + 1);
- AddAffect(SKILL_REFLECT_BUFF, POINT_REFLECT_MELEE, PERFECT_REFLECT_BLESS_AFFECT_VALUE, AFF_REFLECT_BUFF, PERFECT_REFLECT_BLESS_AFFECT_TIME_VALUE, 0, true, true);
- if (item->GetSocket(0) >= PERFECT_REFLECT_BLESS_USINGS)
- {
- ITEM_MANAGER::instance().RemoveItem(item);
- }
- ChatPacket(CHAT_TYPE_INFO, "You are blessed now with: Reflection, [Item Buff] for 310 seconds.");
- ChatPacket(CHAT_TYPE_INFO, "Buff reflection rate applied: 45%.");
- }
- }
- }
- #endif
- //END_PREVENT_TRADE_WINDOW
- if (IS_SET(item->GetFlag(), ITEM_FLAG_LOG))
- {
- DWORD vid = item->GetVID();
- DWORD oldCount = item->GetCount();
- DWORD vnum = item->GetVnum();
- char hint[ITEM_NAME_MAX_LEN + 32 + 1];
- int len = snprintf(hint, sizeof(hint) - 32, "%s", item->GetName());
- if (len < 0 || len >= (int) sizeof(hint) - 32)
- len = (sizeof(hint) - 32) - 1;
- bool ret = UseItemEx(item, DestCell);
- if (NULL == ITEM_MANAGER::instance().FindByVID(vid))
- {
- LogManager::instance().ItemLog(this, vid, vnum, "REMOVE", hint);
- }
- else if (oldCount != item->GetCount())
- {
- snprintf(hint + len, sizeof(hint) - len, " %u", oldCount - 1);
- LogManager::instance().ItemLog(this, vid, vnum, "USE_ITEM", hint);
- }
- return (ret);
- }
- else
- return UseItemEx(item, DestCell);
- }
- bool CHARACTER::DropItem(TItemPos Cell, WORD bCount)
- {
- LPITEM item = NULL;
- if (!CanHandleItem())
- {
- if (NULL != DragonSoul_RefineWindow_GetOpener())
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Alchimie>Obiectul nu poate fi mutat atat timp cat fereastra rafinament este deschisa."));
- return false;
- }
- if (IsDead())
- return false;
- if (!IsValidItemPosition(Cell) || !(item = GetItem(Cell)))
- return false;
- if (item->IsExchanging())
- return false;
- if (true == item->isLocked())
- return false;
- if (quest::CQuestManager::instance().GetPCForce(GetPlayerID())->IsRunning() == true)
- return false;
- if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_DROP | ITEM_ANTIFLAG_GIVE))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti arunca acest item."));
- return false;
- }
- if (bCount == 0 || bCount > item->GetCount())
- bCount = item->GetCount();
- SyncQuickslot(QUICKSLOT_TYPE_ITEM, Cell.cell, 255);
- LPITEM pkItemToDrop;
- if (bCount == item->GetCount())
- {
- item->RemoveFromCharacter();
- pkItemToDrop = item;
- }
- else
- {
- if (bCount == 0)
- {
- if (test_server)
- sys_log(0, "[DROP_ITEM] drop item count == 0");
- return false;
- }
- item->SetCount(item->GetCount() - bCount);
- ITEM_MANAGER::instance().FlushDelayedSave(item);
- pkItemToDrop = ITEM_MANAGER::instance().CreateItem(item->GetVnum(), bCount);
- // copy item socket -- by mhh
- FN_copy_item_socket(pkItemToDrop, item);
- char szBuf[51 + 1];
- snprintf(szBuf, sizeof(szBuf), "%u %u", pkItemToDrop->GetID(), pkItemToDrop->GetCount());
- LogManager::instance().ItemLog(this, item, "ITEM_SPLIT", szBuf);
- }
- PIXEL_POSITION pxPos = GetXYZ();
- if (pkItemToDrop->AddToGround(GetMapIndex(), pxPos))
- {
- if (LC_IsYMIR())
- item->AttrLog();
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Obiectul aruncat va disparea in 5 secunde."));
- pkItemToDrop->StartDestroyEvent(6);
- ITEM_MANAGER::instance().FlushDelayedSave(pkItemToDrop);
- char szHint[32 + 1];
- snprintf(szHint, sizeof(szHint), "%s %u %u", pkItemToDrop->GetName(), pkItemToDrop->GetCount(), pkItemToDrop->GetOriginalVnum());
- LogManager::instance().ItemLog(this, pkItemToDrop, "DROP", szHint);
- //Motion(MOTION_PICKUP);
- }
- return true;
- }
- bool CHARACTER::DestroyItem(TItemPos Cell, DWORD dwCount)
- {
- LPITEM item = NULL;
- if (!CanHandleItem())
- {
- if (NULL != DragonSoul_RefineWindow_GetOpener())
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("¡Æ*E*A¡ËA¡í ¢¯¡þ ¡íoAA¢¯¢®¨ù*¢¥A ¨ú¨¡AIAUA¡í ¢¯A¡¾©¡ ¨ùo ¨ú©ª¨öA¢¥I¢¥U."));
- return false;
- }
- if (IsDead())
- return false;
- if (!IsValidItemPosition(Cell) || !(item = GetItem(Cell)))
- return false;
- if (item->IsExchanging())
- return false;
- if (true == item->isLocked())
- return false;
- if (quest::CQuestManager::instance().GetPCForce(GetPlayerID())->IsRunning() == true)
- return false;
- if (item->GetCount() <= 0)
- return false;
- //if (item->GetVnum() == 91010 || item->GetVnum() == 91011 || item->GetVnum() == 55703 || item->GetVnum() == 55704)
- //{
- // ChatPacket(CHAT_TYPE_INFO,("Nu poti sterge acest obiect."));
- // return false;
- //}
- //DnD obiect util care nu poate fii sters (functional)
- #ifdef NEW_PET_SYSTEM
- if (GetNewPetSystem()->IsActivePet())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Mai intai trimite pet-ul"));
- return false;
- }
- #endif
- SyncQuickslot(QUICKSLOT_TYPE_ITEM, Cell.cell, 255);
- ITEM_MANAGER::instance().RemoveItem(item);
- #ifdef ENABLE_SPECIAL_STORAGE
- if (Cell.IsSpecialInventory())
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai distrus |cFFff0000|H|h[%s]|H|h|r din depozitul special !"), item->GetName());
- else
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai distrus:[%s] !"), item->GetName());
- #else
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai distrus:[%s] !"), item->GetName());
- #endif
- #ifdef __BATTLE_PASS__
- if (!v_counts.empty())
- {
- for (int i=0; i<missions_bp.size(); ++i)
- {
- if (missions_bp[i].type == 4)
- {
- DoMission(i, item->GetCount());
- }
- }
- }
- #endif
- return true;
- }
- #ifdef DISABLE_GOLD_DROP
- bool CHARACTER::DropGold(int gold)
- {
- return false;
- }
- #endif
- bool CHARACTER::MoveItem(TItemPos Cell, TItemPos DestCell, WORD count)
- {
- LPITEM item = NULL;
- if (!IsValidItemPosition(Cell))
- return false;
- if (!(item = GetItem(Cell)))
- return false;
- if (item->IsExchanging())
- return false;
- if (item->GetCount() < count)
- return false;
- if (INVENTORY == Cell.window_type && Cell.cell >= INVENTORY_MAX_NUM && IS_SET(item->GetFlag(), ITEM_FLAG_IRREMOVABLE))
- return false;
- if (true == item->isLocked())
- return false;
- if (!IsValidItemPosition(DestCell))
- {
- return false;
- }
- if (!CanHandleItem())
- {
- if (NULL != DragonSoul_RefineWindow_GetOpener())
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Belt>Acest articol nu poate fi mutat aici"));
- return false;
- }
- if (DestCell.IsBeltInventoryPosition() && false == CBeltInventoryHelper::CanMoveIntoBeltInventory(item))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Belt>Acest articol nu poate fi mutat aici."));
- return false;
- }
- #ifdef ENABLE_SPECIAL_STORAGE
- if (!item->IsUpgradeItem() && UPGRADE_INVENTORY == DestCell.window_type)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga obiecte manual in depozitul special."));
- return false;
- }
- if (!item->IsBook() && BOOK_INVENTORY == DestCell.window_type)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga obiecte manual in depozitul special."));
- return false;
- }
- if (!item->IsStone() && STONE_INVENTORY == DestCell.window_type)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga obiecte manual in depozitul special."));
- return false;
- }
- if (!item->IsDnd() && DND_INVENTORY == DestCell.window_type)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga obiecte manual in depozitul special."));
- return false;
- }
- if (!item->IsGear() && GEAR_INVENTORY == DestCell.window_type)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti adauga obiecte manual in depozitul special."));
- return false;
- }
- #endif
- #ifdef __ATTR_SWITCH_SYSTEM__
- if (Cell.IsSwitchbotPosition() && CSwitchbotManager::Instance().IsActive(GetPlayerID(), Cell.cell))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot move active items here."));
- return false;
- }
- if (DestCell.IsSwitchbotPosition() && !SwitchbotHelper::IsValidItem(item))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot move this item here."));
- return false;
- }
- if ((DestCell.IsSwitchbotPosition() && item->IsEquipped()) || (Cell.IsSwitchbotPosition() && DestCell.IsEquipPosition()))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot move equiped items here."));
- return false;
- }
- #endif
- if (Cell.IsEquipPosition())
- {
- if (!CanUnequipNow(item))
- return false;
- #ifdef ENABLE_WEAPON_COSTUME_SYSTEM
- int iWearCell = item->FindEquipCell(this);
- if (iWearCell == WEAR_WEAPON)
- {
- LPITEM costumeWeapon = GetWear(WEAR_COSTUME_WEAPON);
- if (costumeWeapon && !UnequipItem(costumeWeapon))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot unequip the costume weapon. Not enough space."));
- return false;
- }
- if (!IsEmptyItemGrid(DestCell, item->GetSize(), Cell.cell))
- return UnequipItem(item);
- }
- #endif
- }
- if (DestCell.IsEquipPosition())
- {
- if (GetItem(DestCell))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("<Alchimie>Ai adaugat Piatra Dragon cu succes!"));
- return false;
- }
- EquipItem(item, DestCell.cell - INVENTORY_MAX_NUM);
- }
- else
- {
- if (item->IsDragonSoul())
- {
- if (item->IsEquipped())
- {
- return DSManager::instance().PullOut(this, DestCell, item);
- }
- else
- {
- if (DestCell.window_type != DRAGON_SOUL_INVENTORY)
- {
- return false;
- }
- if (!DSManager::instance().IsValidCellForThisItem(item, DestCell))
- return false;
- }
- }
- else if (DRAGON_SOUL_INVENTORY == DestCell.window_type)
- return false;
- #ifdef ENABLE_SPECIAL_STORAGE
- if (!item->IsUpgradeItem() && UPGRADE_INVENTORY == DestCell.window_type)
- return false;
- if (!item->IsBook() && BOOK_INVENTORY == DestCell.window_type)
- return false;
- if (!item->IsStone() && STONE_INVENTORY == DestCell.window_type)
- return false;
- if (!item->IsDnd() && DND_INVENTORY == DestCell.window_type)
- return false;
- if (!item->IsGear() && GEAR_INVENTORY == DestCell.window_type)
- return false;
- #endif
- LPITEM item2;
- if ((item2 = GetItem(DestCell)) && item != item2 && item2->IsStackable() &&
- !IS_SET(item2->GetAntiFlag(), ITEM_ANTIFLAG_STACK) &&
- item2->GetVnum() == item->GetVnum())
- {
- for (int i = 0; i < ITEM_SOCKET_MAX_NUM; ++i)
- if (item2->GetSocket(i) != item->GetSocket(i))
- return false;
- if (count == 0)
- count = item->GetCount();
- //sys_log(0, "%s: ITEM_STACK %s (window: %d, cell : %d) -> (window:%d, cell %d) count %d", GetName(), item->GetName(), Cell.window_type, Cell.cell,
- //DestCell.window_type, DestCell.cell, count);
- count = MIN(ITEM_MAX_COUNT - item2->GetCount(), count);
- item->SetCount(item->GetCount() - count);
- item2->SetCount(item2->GetCount() + count);
- return true;
- }
- if (!IsEmptyItemGrid(DestCell, item->GetSize(), Cell.cell))
- return false;
- if (count == 0 || count >= item->GetCount() || !item->IsStackable() || IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
- {
- //sys_log(0, "%s: ITEM_MOVE %s (window: %d, cell : %d) -> (window:%d, cell %d) count %d", GetName(), item->GetName(), Cell.window_type, Cell.cell,
- //DestCell.window_type, DestCell.cell, count);
- item->RemoveFromCharacter();
- #ifdef ENABLE_HIGHLIGHT_NEW_ITEM
- SetItem(DestCell, item, true);
- #else
- SetItem(DestCell, item);
- #endif
- #ifdef ENABLE_PET_SLOT
- if(ITEM_NORMAL_PET == item->GetType())
- {
- quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
- }
- #endif
- if (INVENTORY == Cell.window_type && INVENTORY == DestCell.window_type)
- SyncQuickslot(QUICKSLOT_TYPE_ITEM, Cell.cell, DestCell.cell);
- }
- else if (count < item->GetCount())
- {
- sys_log(0, "%s: ITEM_SPLIT %s (window: %d, cell : %d) -> (window:%d, cell %d) count %d", GetName(), item->GetName(), Cell.window_type, Cell.cell,
- DestCell.window_type, DestCell.cell, count);
- item->SetCount(item->GetCount() - count);
- LPITEM item2 = ITEM_MANAGER::instance().CreateItem(item->GetVnum(), count);
- FN_copy_item_socket(item2, item);
- item2->AddToCharacter(this, DestCell);
- char szBuf[51+1];
- snprintf(szBuf, sizeof(szBuf), "%u %u %u %u ", item2->GetID(), item2->GetCount(), item->GetCount(), item->GetCount() + item2->GetCount());
- LogManager::instance().ItemLog(this, item, "ITEM_SPLIT", szBuf);
- }
- }
- return true;
- }
- namespace NPartyPickupDistribute
- {
- struct FFindOwnership
- {
- LPITEM item;
- LPCHARACTER owner;
- FFindOwnership(LPITEM item)
- : item(item), owner(NULL)
- {
- }
- void operator () (LPCHARACTER ch)
- {
- if (item->IsOwnership(ch))
- owner = ch;
- }
- };
- struct FCountNearMember
- {
- int total;
- int x, y;
- FCountNearMember(LPCHARACTER center )
- : total(0), x(center->GetX()), y(center->GetY())
- {
- }
- void operator () (LPCHARACTER ch)
- {
- if (DISTANCE_APPROX(ch->GetX() - x, ch->GetY() - y) <= PARTY_DEFAULT_RANGE)
- total += 1;
- }
- };
- struct FMoneyDistributor
- {
- int total;
- LPCHARACTER c;
- int x, y;
- int iMoney;
- FMoneyDistributor(LPCHARACTER center, int iMoney)
- : total(0), c(center), x(center->GetX()), y(center->GetY()), iMoney(iMoney)
- {
- }
- void operator ()(LPCHARACTER ch)
- {
- if (ch!=c)
- if (DISTANCE_APPROX(ch->GetX() - x, ch->GetY() - y) <= PARTY_DEFAULT_RANGE)
- {
- ch->PointChange(POINT_GOLD, iMoney, true);
- if (iMoney > 1000)
- LogManager::instance().CharLog(ch, iMoney, "GET_GOLD", "");
- }
- }
- };
- }
- void CHARACTER::GiveGold(long long iAmount)
- {
- if (iAmount <= 0)
- return;
- sys_log(0, "GIVE_GOLD: %s %lld", GetName(), iAmount);
- if (GetParty())
- {
- LPPARTY pParty = GetParty();
- long long dwTotal = iAmount;
- long long dwMyAmount = dwTotal;
- NPartyPickupDistribute::FCountNearMember funcCountNearMember(this);
- pParty->ForEachOnlineMember(funcCountNearMember);
- if (funcCountNearMember.total > 1)
- {
- DWORD dwShare = dwTotal / funcCountNearMember.total;
- dwMyAmount -= dwShare * (funcCountNearMember.total - 1);
- NPartyPickupDistribute::FMoneyDistributor funcMoneyDist(this, dwShare);
- pParty->ForEachOnlineMember(funcMoneyDist);
- }
- PointChange(POINT_GOLD, dwMyAmount, true);
- if (dwMyAmount > 1000)
- LogManager::instance().CharLog(this, dwMyAmount, "GET_GOLD", "");
- }
- else
- {
- PointChange(POINT_GOLD, iAmount, true);
- if (LC_IsBrazil() == true)
- {
- if (iAmount >= 213)
- LogManager::instance().CharLog(this, iAmount, "GET_GOLD", "");
- }
- else
- {
- if (iAmount > 1000)
- LogManager::instance().CharLog(this, iAmount, "GET_GOLD", "");
- }
- }
- }
- bool CHARACTER::PickupItem(DWORD dwVID)
- {
- LPITEM item = ITEM_MANAGER::instance().FindByVID(dwVID);
- if (IsObserverMode())
- return false;
- if (!item || !item->GetSectree())
- return false;
- if (item->DistanceValid(this))
- {
- // @fixme150 BEGIN
- if (item->GetType() == ITEM_QUEST)
- {
- if (quest::CQuestManager::instance().GetPCForce(GetPlayerID())->IsRunning() == true)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot pickup this item if you're using quests"));
- return false;
- }
- }
- // @fixme150 END
- if (item->IsOwnership(this))
- {
- if (item->GetType() == ITEM_ELK)
- {
- GiveGold(item->GetCount());
- item->RemoveFromGround();
- M2_DESTROY_ITEM(item);
- Save();
- }
- else
- {
- if ((item->IsBook() || item->IsUpgradeItem() || item->IsStone() || item->IsDnd() || item->IsGear()) && item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
- {
- #ifdef ENABLE_SPECIAL_STORAGE
- if (item->IsUpgradeItem())
- {
- WORD bCount = item->GetCount();
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item2 = GetUpgradeInventoryItem(i);
- if (!item2)
- continue;
- if (item2->GetVnum() == item->GetVnum())
- {
- int j;
- for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
- if (item2->GetSocket(j) != item->GetSocket(j))
- break;
- if (j != ITEM_SOCKET_MAX_NUM)
- continue;
- WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
- bCount -= bCount2;
- item2->SetCount(item2->GetCount() + bCount2);
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Obiectul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item2->GetName());
- if (bCount == 0)
- {
- M2_DESTROY_ITEM(item);
- if (item2->GetType() == ITEM_QUEST)
- quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
- return true;
- }
- }
- }
- item->SetCount(bCount);
- }
- else if (item->IsBook() && item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
- {
- WORD bCount = item->GetCount();
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item2 = GetBookInventoryItem(i);
- if (!item2)
- continue;
- if (item2->GetVnum() == item->GetVnum())
- {
- int j;
- for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
- if (item2->GetSocket(j) != item->GetSocket(j))
- break;
- if (j != ITEM_SOCKET_MAX_NUM)
- continue;
- WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
- bCount -= bCount2;
- item2->SetCount(item2->GetCount() + bCount2);
- if (bCount == 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("|cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item2->GetName());
- M2_DESTROY_ITEM(item);
- if (item2->GetType() == ITEM_SKILLBOOK)
- quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
- return true;
- }
- }
- }
- item->SetCount(bCount);
- }
- else if (item->IsStone() && item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
- {
- WORD bCount = item->GetCount();
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item2 = GetStoneInventoryItem(i);
- if (!item2)
- continue;
- if (item2->GetVnum() == item->GetVnum())
- {
- int j;
- for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
- if (item2->GetSocket(j) != item->GetSocket(j))
- break;
- if (j != ITEM_SOCKET_MAX_NUM)
- continue;
- WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
- bCount -= bCount2;
- item2->SetCount(item2->GetCount() + bCount2);
- if (bCount == 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("|cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item2->GetName());
- M2_DESTROY_ITEM(item);
- if (item2->GetType() == ITEM_METIN)
- quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
- return true;
- }
- }
- }
- item->SetCount(bCount);
- }
- else if (item->IsDnd() && item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
- {
- WORD bCount = item->GetCount();
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item2 = GetDndInventoryItem(i);
- if (!item2)
- continue;
- if (item2->GetVnum() == item->GetVnum())
- {
- WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
- bCount -= bCount2;
- item2->SetCount(item2->GetCount() + bCount2);
- if (bCount == 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("|cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item2->GetName());
- M2_DESTROY_ITEM(item);
- return true;
- }
- }
- }
- item->SetCount(bCount);
- }
- else if (item->IsGear() && item->IsStackable() && !IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_STACK))
- {
- WORD bCount = item->GetCount();
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item2 = GetGearInventoryItem(i);
- if (!item2)
- continue;
- if (item2->GetVnum() == item->GetVnum())
- {
- WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
- bCount -= bCount2;
- item2->SetCount(item2->GetCount() + bCount2);
- if (bCount == 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT(" |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special "), item2->GetName());
- M2_DESTROY_ITEM(item);
- return true;
- }
- }
- }
- item->SetCount(bCount);
- }
- #endif
- else
- {
- WORD bCount = item->GetCount();
- for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item2 = GetInventoryItem(i);
- if (!item2)
- continue;
- if (item2->GetVnum() == item->GetVnum())
- {
- int j;
- for (j = 0; j < ITEM_SOCKET_MAX_NUM; ++j)
- if (item2->GetSocket(j) != item->GetSocket(j))
- break;
- if (j != ITEM_SOCKET_MAX_NUM)
- continue;
- WORD bCount2 = MIN(ITEM_MAX_COUNT - item2->GetCount(), bCount);
- bCount -= bCount2;
- item2->SetCount(item2->GetCount() + bCount2);
- if (bCount == 0)
- {
- ChatPacket(CHAT_TYPE_INFO,("Ai primit %s"), item2->GetName()); //Nu
- M2_DESTROY_ITEM(item);
- if (item2->GetType() == ITEM_QUEST)
- quest::CQuestManager::instance().PickupItem (GetPlayerID(), item2);
- return true;
- }
- }
- }
- item->SetCount(bCount);
- #ifdef ENABLE_SPECIAL_STORAGE
- }
- #endif
- }
- int iEmptyCell;
- if (item->IsDragonSoul())
- {
- if ((iEmptyCell = GetEmptyDragonSoulInventory(item)) == -1)
- {
- sys_log(0, "No empty ds inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
- return false;
- }
- }
- #ifdef ENABLE_SPECIAL_STORAGE
- else if (item->IsUpgradeItem())
- {
- if ((iEmptyCell = GetEmptyUpgradeInventory(item)) == -1)
- {
- sys_log(0, "No empty ssu inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
- return false;
- }
- }
- else if (item->IsBook())
- {
- if ((iEmptyCell = GetEmptyBookInventory(item)) == -1)
- {
- sys_log(0, "No empty ssu inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
- return false;
- }
- }
- else if (item->IsStone())
- {
- if ((iEmptyCell = GetEmptyStoneInventory(item)) == -1)
- {
- sys_log(0, "No empty ssu inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
- return false;
- }
- }
- else if (item->IsDnd())
- {
- if ((iEmptyCell = GetEmptyDndInventory(item)) == -1)
- {
- sys_log(0, "No empty ssu inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
- return false;
- }
- }
- else if (item->IsGear())
- {
- if ((iEmptyCell = GetEmptyGearInventory(item)) == -1)
- {
- sys_log(0, "No empty ssu inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("NoSpace."));
- return false;
- }
- }
- #endif
- else
- {
- if ((iEmptyCell = GetEmptyInventory(item->GetSize())) == -1)
- {
- sys_log(0, "No empty inventory pid %u size %ud itemid %u", GetPlayerID(), item->GetSize(), item->GetID());
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
- return false;
- }
- }
- item->RemoveFromGround();
- if (item->IsDragonSoul())
- item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
- #ifdef ENABLE_SPECIAL_STORAGE
- else if (item->IsUpgradeItem())
- {
- item->AddToCharacter(this, TItemPos(UPGRADE_INVENTORY, iEmptyCell));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Obiectul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
- }
- else if (item->IsBook())
- {
- item->AddToCharacter(this, TItemPos(BOOK_INVENTORY, iEmptyCell));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT(" |cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item->GetName());
- }
- else if (item->IsStone())
- {
- item->AddToCharacter(this, TItemPos(STONE_INVENTORY, iEmptyCell));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT(" |cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item->GetName());
- }
- else if (item->IsDnd())
- {
- item->AddToCharacter(this, TItemPos(DND_INVENTORY, iEmptyCell));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Cufarul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
- }
- else if (item->IsGear())
- {
- item->AddToCharacter(this, TItemPos(GEAR_INVENTORY, iEmptyCell));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT(" |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special! "), item->GetName());
- }
- #endif
- else
- {
- item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s"), item->GetName()); //EDIT DND
- }
- char szHint[32+1];
- snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
- LogManager::instance().ItemLog(this, item, "GET", szHint);
- if (item->GetType() == ITEM_QUEST)
- quest::CQuestManager::instance().PickupItem (GetPlayerID(), item);
- }
- //Motion(MOTION_PICKUP);
- return true;
- }
- else if (!IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_GIVE | ITEM_ANTIFLAG_DROP) && GetParty())
- {
- NPartyPickupDistribute::FFindOwnership funcFindOwnership(item);
- GetParty()->ForEachOnlineMember(funcFindOwnership);
- LPCHARACTER owner = funcFindOwnership.owner;
- // @fixme115
- if (!owner)
- return false;
- int iEmptyCell;
- if (item->IsDragonSoul())
- {
- if (!(owner && (iEmptyCell = owner->GetEmptyDragonSoulInventory(item)) != -1))
- {
- owner = this;
- if ((iEmptyCell = GetEmptyDragonSoulInventory(item)) == -1)
- {
- owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
- return false;
- }
- }
- }
- #ifdef ENABLE_SPECIAL_STORAGE
- else if (item->IsUpgradeItem())
- {
- if (!(owner && (iEmptyCell = owner->GetEmptyUpgradeInventory(item)) != -1))
- {
- owner = this;
- if ((iEmptyCell = GetEmptyUpgradeInventory(item)) == -1)
- {
- owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
- return false;
- }
- }
- }
- else if (item->IsBook())
- {
- if (!(owner && (iEmptyCell = owner->GetEmptyBookInventory(item)) != -1))
- {
- owner = this;
- if ((iEmptyCell = GetEmptyBookInventory(item)) == -1)
- {
- owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
- return false;
- }
- }
- }
- else if (item->IsStone())
- {
- if (!(owner && (iEmptyCell = owner->GetEmptyStoneInventory(item)) != -1))
- {
- owner = this;
- if ((iEmptyCell = GetEmptyStoneInventory(item)) == -1)
- {
- owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
- return false;
- }
- }
- }
- else if (item->IsDnd())
- {
- if (!(owner && (iEmptyCell = owner->GetEmptyDndInventory(item)) != -1))
- {
- owner = this;
- if ((iEmptyCell = GetEmptyDndInventory(item)) == -1)
- {
- owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
- return false;
- }
- }
- }
- else if (item->IsGear())
- {
- if (!(owner && (iEmptyCell = owner->GetEmptyGearInventory(item)) != -1))
- {
- owner = this;
- if ((iEmptyCell = GetEmptyGearInventory(item)) == -1)
- {
- owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
- return false;
- }
- }
- }
- #endif
- else
- {
- if (!(owner && (iEmptyCell = owner->GetEmptyInventory(item->GetSize())) != -1))
- {
- owner = this;
- if ((iEmptyCell = GetEmptyInventory(item->GetSize())) == -1)
- {
- owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai prea multe obiecte in inventar."));
- return false;
- }
- }
- }
- item->RemoveFromGround();
- if (item->IsDragonSoul())
- item->AddToCharacter(owner, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
- #ifdef ENABLE_SPECIAL_STORAGE
- else if (item->IsUpgradeItem())
- item->AddToCharacter(owner, TItemPos(UPGRADE_INVENTORY, iEmptyCell));
- else if (item->IsBook())
- item->AddToCharacter(owner, TItemPos(BOOK_INVENTORY, iEmptyCell));
- else if (item->IsStone())
- item->AddToCharacter(owner, TItemPos(STONE_INVENTORY, iEmptyCell));
- else if (item->IsDnd())
- item->AddToCharacter(owner, TItemPos(DND_INVENTORY, iEmptyCell));
- else if (item->IsGear())
- item->AddToCharacter(owner, TItemPos(GEAR_INVENTORY, iEmptyCell));
- #endif
- else
- item->AddToCharacter(owner, TItemPos(INVENTORY, iEmptyCell));
- char szHint[32+1];
- snprintf(szHint, sizeof(szHint), "%s %u %u", item->GetName(), item->GetCount(), item->GetOriginalVnum());
- LogManager::instance().ItemLog(owner, item, "GET", szHint);
- if (owner == this)
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit %s"), item->GetName()); // Nu
- else
- {
- owner->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit: %s de la %s"), GetName(), item->GetName());
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai dat %s lui %s"), owner->GetName(), item->GetName());
- }
- if (item->GetType() == ITEM_QUEST)
- quest::CQuestManager::instance().PickupItem (owner->GetPlayerID(), item);
- return true;
- }
- }
- return false;
- }
- bool CHARACTER::SwapItem(BYTE bCell, BYTE bDestCell)
- {
- if (!CanHandleItem())
- return false;
- TItemPos srcCell(INVENTORY, bCell), destCell(INVENTORY, bDestCell);
- if (srcCell.IsDragonSoulEquipPosition() || destCell.IsDragonSoulEquipPosition())
- return false;
- if (bCell == bDestCell)
- return false;
- if (srcCell.IsEquipPosition() && destCell.IsEquipPosition())
- return false;
- LPITEM item1, item2;
- if (srcCell.IsEquipPosition())
- {
- item1 = GetInventoryItem(bDestCell);
- item2 = GetInventoryItem(bCell);
- }
- else
- {
- item1 = GetInventoryItem(bCell);
- item2 = GetInventoryItem(bDestCell);
- }
- if (!item1 || !item2)
- return false;
- if (item1 == item2)
- {
- sys_log(0, "[WARNING][WARNING][HACK USER!] : %s %d %d", m_stName.c_str(), bCell, bDestCell);
- return false;
- }
- if (!IsEmptyItemGrid(TItemPos (INVENTORY, item1->GetCell()), item2->GetSize(), item1->GetCell()))
- return false;
- if (TItemPos(EQUIPMENT, item2->GetCell()).IsEquipPosition())
- {
- BYTE bEquipCell = item2->GetCell() - INVENTORY_MAX_NUM;
- BYTE bInvenCell = item1->GetCell();
- #ifdef CHANGE_EQ_FULL_INV_FIX
- if (false == CanEquipNow(item1))
- return false;
- if (item2->IsDragonSoul() && false == CanUnequipNow(item2))
- return false;
- #endif
- if (item2->IsDragonSoul() || item2->GetType() == ITEM_BELT) // @fixme117
- {
- if (false == CanUnequipNow(item2) || false == CanEquipNow(item1))
- return false;
- }
- if (GetWear(WEAR_COSTUME_WEAPON) && item1->GetType() == ITEM_ROD || GetWear(WEAR_COSTUME_WEAPON) && item1->GetType() == ITEM_PICK) // // block fish rod and pick
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("costume_weapon_on_rod"));
- return false;
- }
- if (bEquipCell != item1->FindEquipCell(this))
- return false;
- #ifdef ENABLE_PET_SLOT
- if(ITEM_NORMAL_PET == item2->GetType())
- {
- quest::CQuestManager::instance().UseItem(GetPlayerID(), item2, false);
- }
- #endif
- item2->RemoveFromCharacter();
- if (item1->EquipTo(this, bEquipCell))
- item2->AddToCharacter(this, TItemPos(INVENTORY, bInvenCell));
- else
- sys_err("SwapItem cannot equip %s! item1 %s", item2->GetName(), item1->GetName());
- }
- else
- {
- BYTE bCell1 = item1->GetCell();
- BYTE bCell2 = item2->GetCell();
- item1->RemoveFromCharacter();
- item2->RemoveFromCharacter();
- item1->AddToCharacter(this, TItemPos(INVENTORY, bCell2));
- item2->AddToCharacter(this, TItemPos(INVENTORY, bCell1));
- }
- return true;
- }
- bool CHARACTER::UnequipItem(LPITEM item)
- {
- #ifdef ENABLE_WEAPON_COSTUME_SYSTEM
- int iWearCell = item->FindEquipCell(this);
- if (iWearCell == WEAR_WEAPON)
- {
- LPITEM costumeWeapon = GetWear(WEAR_COSTUME_WEAPON);
- if (costumeWeapon && !UnequipItem(costumeWeapon))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot unequip the costume weapon. Not enough space."));
- return false;
- }
- }
- #endif
- if (false == CanUnequipNow(item))
- return false;
- int pos;
- if (item->IsDragonSoul())
- pos = GetEmptyDragonSoulInventory(item);
- #ifdef ENABLE_SPECIAL_STORAGE
- else if (item->IsBook())
- pos = GetEmptyBookInventory(item);
- else if (item->IsUpgradeItem())
- pos = GetEmptyUpgradeInventory(item);
- else if (item->IsStone())
- pos = GetEmptyStoneInventory(item);
- else if (item->IsDnd())
- pos = GetEmptyDndInventory(item);
- else if (item->IsGear())
- pos = GetEmptyGearInventory(item);
- #endif
- else
- pos = GetEmptyInventory(item->GetSize());
- // HARD CODING
- if (item->GetVnum() == UNIQUE_ITEM_HIDE_ALIGNMENT_TITLE)
- ShowAlignment(true);
- #ifdef ENABLE_PET_SLOT
- if(ITEM_NORMAL_PET == item->GetType())
- {
- quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
- }
- #endif
- item->RemoveFromCharacter();
- if (item->IsDragonSoul())
- {
- item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, pos));
- }
- else
- item->AddToCharacter(this, TItemPos(INVENTORY, pos));
- CheckMaximumPoints();
- return true;
- }
- bool CHARACTER::EquipItem(LPITEM item, int iCandidateCell)
- {
- #ifdef BELT_INVENTORY_FIX
- LPITEM belt1,belt2;
- #endif
- if (item->IsExchanging())
- return false;
- if (false == item->IsEquipable())
- return false;
- if (false == CanEquipNow(item))
- return false;
- int iWearCell = item->FindEquipCell(this, iCandidateCell);
- TItemPos srcCell(INVENTORY, item->GetCell()), destCell(INVENTORY, INVENTORY_MAX_NUM + iWearCell);
- if (iWearCell < 0)
- return false;
- if (iWearCell != WEAR_ARROW && IsPolymorphed())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu iti poti schimba itemele cat timp esti transformat."));
- return false;
- }
- //fix dnd costum nunta end
- if (GetWear(WEAR_COSTUME_BODY) && item->GetVnum() >= 11901 && item->GetVnum() <= 11904)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti purta un costum atat timp cat ai echipat un obiect de nunta."));
- return false;
- }
- if (FN_check_item_sex(this, item) == false)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest articol nu poate fi deschis deoarece sexul este incorect"));
- return false;
- }
- if(item->IsRideItem() && IsRiding())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Poti sa te dai jos de pe acest mount apasand ctrl + g !."));
- return false;
- }
- DWORD dwCurTime = get_dword_time();
- if (iWearCell != WEAR_ARROW
- && (dwCurTime - GetLastAttackTime() <= 1500 || dwCurTime - m_dwLastSkillTime <= 1500))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asta."));
- return false;
- }
- #ifdef ENABLE_WEAPON_COSTUME_SYSTEM
- if (iWearCell == WEAR_WEAPON)
- {
- if (item->GetType() == ITEM_WEAPON)
- {
- LPITEM costumeWeapon = GetWear(WEAR_COSTUME_WEAPON);
- if (costumeWeapon && costumeWeapon->GetValue(3) != item->GetSubType() && !UnequipItem(costumeWeapon))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot unequip the costume weapon. Not enough space."));
- return false;
- }
- }
- else //fishrod/pickaxe
- {
- LPITEM costumeWeapon = GetWear(WEAR_COSTUME_WEAPON);
- if (costumeWeapon && !UnequipItem(costumeWeapon))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot unequip the costume weapon. Not enough space."));
- return false;
- }
- }
- }
- else if (iWearCell == WEAR_COSTUME_WEAPON)
- {
- if (item->GetType() == ITEM_COSTUME && item->GetSubType() == COSTUME_WEAPON)
- {
- LPITEM pkWeapon = GetWear(WEAR_WEAPON);
- if (!pkWeapon || pkWeapon->GetType() != ITEM_WEAPON || item->GetValue(3) != pkWeapon->GetSubType())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You cannot equip the costume weapon. Wrong equipped weapon."));
- return false;
- }
- }
- }
- #endif
- if (item->IsDragonSoul())
- {
- if(GetInventoryItem(INVENTORY_MAX_NUM + iWearCell))
- {
- ChatPacket(CHAT_TYPE_INFO, "ÀÌ¹Ì °°Àº Á¾·ùÀÇ ¿ëÈ¥¼®À» Âø¿ëÇϰí ÀÖ½À´Ï´Ù.");
- return false;
- }
- if (!item->EquipTo(this, iWearCell))
- {
- return false;
- }
- }
- else
- {
- if (GetWear(iWearCell) && !IS_SET(GetWear(iWearCell)->GetFlag(), ITEM_FLAG_IRREMOVABLE))
- {
- if (item->GetWearFlag() == WEARABLE_ABILITY)
- return false;
- #ifdef BELT_INVENTORY_FIX
- if (srcCell.IsEquipPosition())
- {
- belt1 = GetInventoryItem(INVENTORY_MAX_NUM + iWearCell);
- belt2 = GetInventoryItem(item->GetCell());
- }
- else
- {
- belt1 = GetInventoryItem(item->GetCell());
- belt2 = GetInventoryItem(INVENTORY_MAX_NUM + iWearCell);
- }
- if ((ITEM_BELT == belt2->GetType()) && (CBeltInventoryHelper::IsExistItemInBeltInventory(this) == true))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asta!"));
- return false;
- }
- #endif
- if (false == SwapItem(item->GetCell(), INVENTORY_MAX_NUM + iWearCell))
- {
- return false;
- }
- }
- else
- {
- BYTE bOldCell = item->GetCell();
- if (item->EquipTo(this, iWearCell))
- {
- SyncQuickslot(QUICKSLOT_TYPE_ITEM, bOldCell, iWearCell);
- }
- }
- }
- if (true == item->IsEquipped())
- {
- if (-1 != item->GetProto()->cLimitRealTimeFirstUseIndex)
- {
- if (0 == item->GetSocket(1))
- {
- long duration = (0 != item->GetSocket(0)) ? item->GetSocket(0) : item->GetProto()->aLimits[item->GetProto()->cLimitRealTimeFirstUseIndex].lValue;
- if (0 == duration)
- duration = 60 * 60 * 24 * 7;
- item->SetSocket(0, time(0) + duration);
- item->StartRealTimeExpireEvent();
- }
- item->SetSocket(1, item->GetSocket(1) + 1);
- }
- if (item->GetVnum() == UNIQUE_ITEM_HIDE_ALIGNMENT_TITLE)
- ShowAlignment(false);
- const DWORD& dwVnum = item->GetVnum();
- if (true == CItemVnumHelper::IsRamadanMoonRing(dwVnum))
- {
- this->EffectPacket(SE_EQUIP_RAMADAN_RING);
- }
- else if (true == CItemVnumHelper::IsHalloweenCandy(dwVnum))
- {
- this->EffectPacket(SE_EQUIP_HALLOWEEN_CANDY);
- }
- else if (true == CItemVnumHelper::IsHappinessRing(dwVnum))
- {
- this->EffectPacket(SE_EQUIP_HAPPINESS_RING);
- }
- //(71145)
- else if (true == CItemVnumHelper::IsLovePendant(dwVnum))
- {
- this->EffectPacket(SE_EQUIP_LOVE_PENDANT);
- }
- // ITEM_UNIQUEÀÇ °æ¿ì, SpecialItemGroup¿¡ Á¤ÀǵǾî ÀÖ°í, (item->GetSIGVnum() != NULL)
- //
- else if (true == CItemVnumHelper::IsEGY1(dwVnum))
- {
- this->EffectPacket(SE_EQUIP_EGY1);
- }
- else if (true == CItemVnumHelper::IsEGY2(dwVnum))
- {
- this->EffectPacket(SE_EQUIP_EGY2);
- }
- else if (true == CItemVnumHelper::IsSEA1(dwVnum))
- {
- this->EffectPacket(SE_EQUIP_SEA1);
- }
- else if (true == CItemVnumHelper::IsSEA2(dwVnum))
- {
- this->EffectPacket(SE_EQUIP_SEA2);
- }
- else if (true == CItemVnumHelper::IsDEM1(dwVnum))
- {
- this->EffectPacket(SE_EQUIP_DEM1);
- }
- else if (true == CItemVnumHelper::IsDEM2(dwVnum))
- {
- this->EffectPacket(SE_EQUIP_DEM2);
- }
- else if (true == CItemVnumHelper::IsATK1(dwVnum))
- {
- this->EffectPacket(SE_EQUIP_ATK1);
- }
- else if (true == CItemVnumHelper::IsAPR2(dwVnum))
- {
- this->EffectPacket(SE_EQUIP_APR2);
- }
- else if (ITEM_UNIQUE == item->GetType() && 0 != item->GetSIGVnum())
- {
- const CSpecialItemGroup* pGroup = ITEM_MANAGER::instance().GetSpecialItemGroup(item->GetSIGVnum());
- if (NULL != pGroup)
- {
- const CSpecialAttrGroup* pAttrGroup = ITEM_MANAGER::instance().GetSpecialAttrGroup(pGroup->GetAttrVnum(item->GetVnum()));
- if (NULL != pAttrGroup)
- {
- const std::string& std = pAttrGroup->m_stEffectFileName;
- SpecificEffectPacket(std.c_str());
- }
- }
- }
- #ifdef __SASH_SYSTEM__
- else if ((item->GetType() == ITEM_COSTUME) && (item->GetSubType() == COSTUME_SASH))
- this->EffectPacket(SE_EFFECT_SASH_EQUIP);
- #endif
- if (
- (ITEM_UNIQUE == item->GetType() && UNIQUE_SPECIAL_RIDE == item->GetSubType() && IS_SET(item->GetFlag(), ITEM_FLAG_QUEST_USE))
- || (ITEM_UNIQUE == item->GetType() && UNIQUE_SPECIAL_MOUNT_RIDE == item->GetSubType() && IS_SET(item->GetFlag(), ITEM_FLAG_QUEST_USE)))
- {
- quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
- }
- if (COSTUME_MOUNT == item->GetSubType())
- {
- quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
- }
- #ifdef ENABLE_PET_SLOT
- else if(ITEM_NORMAL_PET == item->GetType())
- {
- quest::CQuestManager::instance().UseItem(GetPlayerID(), item, false);
- }
- #endif
- }
- return true;
- }
- void CHARACTER::BuffOnAttr_AddBuffsFromItem(LPITEM pItem)
- {
- for (size_t i = 0; i < sizeof(g_aBuffOnAttrPoints)/sizeof(g_aBuffOnAttrPoints[0]); i++)
- {
- TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.find(g_aBuffOnAttrPoints[i]);
- if (it != m_map_buff_on_attrs.end())
- {
- it->second->AddBuffFromItem(pItem);
- }
- }
- }
- void CHARACTER::BuffOnAttr_RemoveBuffsFromItem(LPITEM pItem)
- {
- for (size_t i = 0; i < sizeof(g_aBuffOnAttrPoints)/sizeof(g_aBuffOnAttrPoints[0]); i++)
- {
- TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.find(g_aBuffOnAttrPoints[i]);
- if (it != m_map_buff_on_attrs.end())
- {
- it->second->RemoveBuffFromItem(pItem);
- }
- }
- }
- void CHARACTER::BuffOnAttr_ClearAll()
- {
- for (TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.begin(); it != m_map_buff_on_attrs.end(); it++)
- {
- CBuffOnAttributes* pBuff = it->second;
- if (pBuff)
- {
- pBuff->Initialize();
- }
- }
- }
- void CHARACTER::BuffOnAttr_ValueChange(BYTE bType, BYTE bOldValue, BYTE bNewValue)
- {
- TMapBuffOnAttrs::iterator it = m_map_buff_on_attrs.find(bType);
- if (0 == bNewValue)
- {
- if (m_map_buff_on_attrs.end() == it)
- return;
- else
- it->second->Off();
- }
- else if(0 == bOldValue)
- {
- CBuffOnAttributes* pBuff = NULL;
- if (m_map_buff_on_attrs.end() == it)
- {
- switch (bType)
- {
- case POINT_ENERGY:
- {
- static BYTE abSlot[] = { WEAR_BODY, WEAR_HEAD, WEAR_FOOTS, WEAR_WRIST, WEAR_WEAPON, WEAR_NECK, WEAR_EAR, WEAR_SHIELD };
- static std::vector <BYTE> vec_slots (abSlot, abSlot + _countof(abSlot));
- pBuff = M2_NEW CBuffOnAttributes(this, bType, &vec_slots);
- }
- break;
- case POINT_COSTUME_ATTR_BONUS:
- {
- static BYTE abSlot[] = {
- WEAR_COSTUME_BODY,
- WEAR_COSTUME_HAIR,
- WEAR_COSTUME_MOUNT,
- #ifdef __WEAPON_COSTUME_SYSTEM__
- WEAR_COSTUME_WEAPON,
- #endif
- };
- static std::vector <BYTE> vec_slots (abSlot, abSlot + _countof(abSlot));
- pBuff = M2_NEW CBuffOnAttributes(this, bType, &vec_slots);
- }
- break;
- default:
- break;
- }
- m_map_buff_on_attrs.insert(TMapBuffOnAttrs::value_type(bType, pBuff));
- }
- else
- pBuff = it->second;
- if (pBuff != NULL)
- pBuff->On(bNewValue);
- }
- else
- {
- assert (m_map_buff_on_attrs.end() != it);
- it->second->ChangeBuffValue(bNewValue);
- }
- }
- LPITEM CHARACTER::FindSpecifyItem(DWORD vnum) const
- {
- for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
- if (GetInventoryItem(i) && GetInventoryItem(i)->GetVnum() == vnum)
- return GetInventoryItem(i);
- return NULL;
- }
- LPITEM CHARACTER::FindItemByID(DWORD id) const
- {
- for (int i = 0 ; i < INVENTORY_MAX_NUM ; ++i)
- {
- if (NULL != GetInventoryItem(i) && GetInventoryItem(i)->GetID() == id)
- return GetInventoryItem(i);
- }
- for (int i=BELT_INVENTORY_SLOT_START; i < BELT_INVENTORY_SLOT_END ; ++i)
- {
- if (NULL != GetInventoryItem(i) && GetInventoryItem(i)->GetID() == id)
- return GetInventoryItem(i);
- }
- return NULL;
- }
- int CHARACTER::CountSpecifyItem(DWORD vnum) const
- {
- int count = 0;
- LPITEM item;
- for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
- {
- item = GetInventoryItem(i);
- if (NULL != item && item->GetVnum() == vnum)
- {
- if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
- {
- continue;
- }
- else
- {
- count += item->GetCount();
- }
- }
- }
- #ifdef ENABLE_SPECIAL_STORAGE
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- item = GetUpgradeInventoryItem(i);
- if (NULL != item && item->GetVnum() == vnum)
- {
- if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
- continue;
- else
- count += item->GetCount();
- }
- }
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- item = GetBookInventoryItem(i);
- if (NULL != item && item->GetVnum() == vnum)
- {
- if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
- continue;
- else
- count += item->GetCount();
- }
- }
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- item = GetStoneInventoryItem(i);
- if (NULL != item && item->GetVnum() == vnum)
- {
- if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
- continue;
- else
- count += item->GetCount();
- }
- }
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- item = GetDndInventoryItem(i);
- if (NULL != item && item->GetVnum() == vnum)
- {
- if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
- continue;
- else
- count += item->GetCount();
- }
- }
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- item = GetGearInventoryItem(i);
- if (NULL != item && item->GetVnum() == vnum)
- {
- if (m_pkMyShop && m_pkMyShop->IsSellingItem(item->GetID()))
- continue;
- else
- count += item->GetCount();
- }
- }
- #endif
- return count;
- }
- void CHARACTER::RemoveSpecifyItem(DWORD vnum, DWORD count)
- {
- if (0 == count)
- return;
- for (UINT i = 0; i < INVENTORY_MAX_NUM; ++i)
- {
- if (NULL == GetInventoryItem(i))
- continue;
- if (GetInventoryItem(i)->GetVnum() != vnum)
- continue;
- if(m_pkMyShop)
- {
- bool isItemSelling = m_pkMyShop->IsSellingItem(GetInventoryItem(i)->GetID());
- if (isItemSelling)
- continue;
- }
- if (vnum >= 80003 && vnum <= 80007)
- LogManager::instance().GoldBarLog(GetPlayerID(), GetInventoryItem(i)->GetID(), QUEST, "RemoveSpecifyItem");
- if (count >= GetInventoryItem(i)->GetCount())
- {
- count -= GetInventoryItem(i)->GetCount();
- GetInventoryItem(i)->SetCount(0);
- if (0 == count)
- return;
- }
- else
- {
- GetInventoryItem(i)->SetCount(GetInventoryItem(i)->GetCount() - count);
- return;
- }
- }
- #ifdef ENABLE_SPECIAL_STORAGE
- for (UINT i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- if (NULL == GetUpgradeInventoryItem(i))
- continue;
- if (GetUpgradeInventoryItem(i)->GetVnum() != vnum)
- continue;
- if(m_pkMyShop)
- {
- bool isItemSelling = m_pkMyShop->IsSellingItem(GetUpgradeInventoryItem(i)->GetID());
- if (isItemSelling)
- continue;
- }
- if (count >= GetUpgradeInventoryItem(i)->GetCount())
- {
- count -= GetUpgradeInventoryItem(i)->GetCount();
- GetUpgradeInventoryItem(i)->SetCount(0);
- if (0 == count)
- return;
- }
- else
- {
- GetUpgradeInventoryItem(i)->SetCount(GetUpgradeInventoryItem(i)->GetCount() - count);
- return;
- }
- }
- for (UINT i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- if (NULL == GetBookInventoryItem(i))
- continue;
- if (GetBookInventoryItem(i)->GetVnum() != vnum)
- continue;
- if(m_pkMyShop)
- {
- bool isItemSelling = m_pkMyShop->IsSellingItem(GetBookInventoryItem(i)->GetID());
- if (isItemSelling)
- continue;
- }
- if (count >= GetBookInventoryItem(i)->GetCount())
- {
- count -= GetBookInventoryItem(i)->GetCount();
- GetBookInventoryItem(i)->SetCount(0);
- if (0 == count)
- return;
- }
- else
- {
- GetBookInventoryItem(i)->SetCount(GetBookInventoryItem(i)->GetCount() - count);
- return;
- }
- }
- for (UINT i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- if (NULL == GetStoneInventoryItem(i))
- continue;
- if (GetStoneInventoryItem(i)->GetVnum() != vnum)
- continue;
- if(m_pkMyShop)
- {
- bool isItemSelling = m_pkMyShop->IsSellingItem(GetStoneInventoryItem(i)->GetID());
- if (isItemSelling)
- continue;
- }
- if (count >= GetStoneInventoryItem(i)->GetCount())
- {
- count -= GetStoneInventoryItem(i)->GetCount();
- GetStoneInventoryItem(i)->SetCount(0);
- if (0 == count)
- return;
- }
- else
- {
- GetStoneInventoryItem(i)->SetCount(GetStoneInventoryItem(i)->GetCount() - count);
- return;
- }
- }
- for (UINT i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- if (NULL == GetDndInventoryItem(i))
- continue;
- if (GetDndInventoryItem(i)->GetVnum() != vnum)
- continue;
- if(m_pkMyShop)
- {
- bool isItemSelling = m_pkMyShop->IsSellingItem(GetDndInventoryItem(i)->GetID());
- if (isItemSelling)
- continue;
- }
- if (count >= GetDndInventoryItem(i)->GetCount())
- {
- count -= GetDndInventoryItem(i)->GetCount();
- GetDndInventoryItem(i)->SetCount(0);
- if (0 == count)
- return;
- }
- else
- {
- GetDndInventoryItem(i)->SetCount(GetDndInventoryItem(i)->GetCount() - count);
- return;
- }
- }
- for (UINT i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- if (NULL == GetGearInventoryItem(i))
- continue;
- if (GetGearInventoryItem(i)->GetVnum() != vnum)
- continue;
- if(m_pkMyShop)
- {
- bool isItemSelling = m_pkMyShop->IsSellingItem(GetGearInventoryItem(i)->GetID());
- if (isItemSelling)
- continue;
- }
- if (count >= GetGearInventoryItem(i)->GetCount())
- {
- count -= GetGearInventoryItem(i)->GetCount();
- GetGearInventoryItem(i)->SetCount(0);
- if (0 == count)
- return;
- }
- else
- {
- GetGearInventoryItem(i)->SetCount(GetGearInventoryItem(i)->GetCount() - count);
- return;
- }
- }
- #endif
- // ¿¹¿Ü󸮰¡ ¾àÇÏ´Ù.
- if (count)
- sys_log(0, "CHARACTER::RemoveSpecifyItem cannot remove enough item vnum %u, still remain %d", vnum, count);
- }
- int CHARACTER::CountSpecifyTypeItem(BYTE type) const
- {
- int count = 0;
- for (UINT i = 0; i < INVENTORY_MAX_NUM; ++i)
- {
- LPITEM pItem = GetInventoryItem(i);
- if (pItem != NULL && pItem->GetType() == type)
- {
- count += pItem->GetCount();
- }
- }
- return count;
- }
- void CHARACTER::RemoveSpecifyTypeItem(BYTE type, DWORD count)
- {
- if (0 == count)
- return;
- for (UINT i = 0; i < INVENTORY_MAX_NUM; ++i)
- {
- if (NULL == GetInventoryItem(i))
- continue;
- if (GetInventoryItem(i)->GetType() != type)
- continue;
- if(m_pkMyShop)
- {
- bool isItemSelling = m_pkMyShop->IsSellingItem(GetInventoryItem(i)->GetID());
- if (isItemSelling)
- continue;
- }
- if (count >= GetInventoryItem(i)->GetCount())
- {
- count -= GetInventoryItem(i)->GetCount();
- GetInventoryItem(i)->SetCount(0);
- if (0 == count)
- return;
- }
- else
- {
- GetInventoryItem(i)->SetCount(GetInventoryItem(i)->GetCount() - count);
- return;
- }
- }
- }
- #ifdef ENABLE_SORT_INVENTORY
- void CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip, bool bWereMine)
- #else
- void CHARACTER::AutoGiveItem(LPITEM item, bool longOwnerShip)
- #endif
- {
- if (NULL == item)
- {
- sys_err ("NULL point.");
- return;
- }
- if (item->GetOwner())
- {
- sys_err ("item %d 's owner exists!",item->GetID());
- return;
- }
- int cell;
- if (item->IsDragonSoul())
- {
- cell = GetEmptyDragonSoulInventory(item);
- }
- #ifdef ENABLE_SPECIAL_STORAGE
- else if (item->IsUpgradeItem())
- {
- cell = GetEmptyUpgradeInventory(item);
- }
- else if (item->IsBook())
- {
- cell = GetEmptyBookInventory(item);
- }
- else if (item->IsStone())
- {
- cell = GetEmptyStoneInventory(item);
- }
- else if (item->IsDnd())
- {
- cell = GetEmptyDndInventory(item);
- }
- else if (item->IsGear())
- {
- cell = GetEmptyGearInventory(item);
- }
- #endif
- else
- {
- cell = GetEmptyInventory (item->GetSize());
- }
- if (cell != -1)
- {
- if (item->IsDragonSoul())
- item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, cell));
- #ifdef ENABLE_SPECIAL_STORAGE
- else if (item->IsUpgradeItem())
- item->AddToCharacter(this, TItemPos(UPGRADE_INVENTORY, cell));
- else if (item->IsBook())
- item->AddToCharacter(this, TItemPos(BOOK_INVENTORY, cell));
- else if (item->IsStone())
- item->AddToCharacter(this, TItemPos(STONE_INVENTORY, cell));
- else if (item->IsDnd())
- item->AddToCharacter(this, TItemPos(DND_INVENTORY, cell));
- else if (item->IsGear())
- item->AddToCharacter(this, TItemPos(GEAR_INVENTORY, cell));
- #endif
- else
- //item->AddToCharacter(this, TItemPos(INVENTORY, cell));
- #ifdef ENABLE_SORT_INVENTORY
- item->AddToCharacter(this, TItemPos(INVENTORY, cell), bWereMine);
- #else
- item->AddToCharacter(this, TItemPos(INVENTORY, cell));
- #endif
- LogManager::instance().ItemLog(this, item, "SYSTEM", item->GetName());
- if (item->GetType() == ITEM_USE && item->GetSubType() == USE_POTION)
- {
- TQuickslot * pSlot;
- if (GetQuickslot(0, &pSlot) && pSlot->type == QUICKSLOT_TYPE_NONE)
- {
- TQuickslot slot;
- slot.type = QUICKSLOT_TYPE_ITEM;
- slot.pos = cell;
- SetQuickslot(0, slot);
- }
- }
- }
- else
- {
- item->AddToGround (GetMapIndex(), GetXYZ());
- item->StartDestroyEvent();
- if (longOwnerShip)
- item->SetOwnership (this, 10); //DnD works -spam 30s
- else
- item->SetOwnership (this, 6); //DnD works -spam 25s
- LogManager::instance().ItemLog(this, item, "SYSTEM_DROP", item->GetName());
- }
- }
- #ifdef ENABLE_SORT_INVENTORY
- LPITEM CHARACTER::AutoGiveItem(DWORD dwItemVnum, WORD bCount, int iRarePct, bool bMsg, bool bWereMine)
- #else
- LPITEM CHARACTER::AutoGiveItem(DWORD dwItemVnum, WORD bCount, int iRarePct, bool bMsg)
- #endif
- {
- TItemTable * p = ITEM_MANAGER::instance().GetTable(dwItemVnum);
- if (!p)
- return NULL;
- DBManager::instance().SendMoneyLog(MONEY_LOG_DROP, dwItemVnum, bCount);
- if (p->dwFlags & ITEM_FLAG_STACKABLE && p->bType != ITEM_BLEND)
- {
- #ifdef ENABLE_SPECIAL_STORAGE
- if (p->bType == ITEM_MATERIAL && p->bSubType == MATERIAL_LEATHER) //upgrade item
- {
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item = GetUpgradeInventoryItem(i);
- if (!item)
- continue;
- if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
- {
- if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
- {
- if (bCount < p->alValues[1])
- bCount = p->alValues[1];
- }
- WORD bCount2 = MIN(ITEM_MAX_COUNT - item->GetCount(), bCount);
- bCount -= bCount2;
- item->SetCount(item->GetCount() + bCount2);
- if (bCount == 0)
- {
- if (bMsg)
- ChatPacket(CHAT_TYPE_INFO, ("Obiectul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
- return item;
- }
- }
- }
- }
- else if (dwItemVnum == 50300) //book item
- {
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item = GetBookInventoryItem(i);
- if (!item)
- continue;
- if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
- {
- if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
- {
- if (bCount < p->alValues[1])
- bCount = p->alValues[1];
- }
- WORD bCount2 = MIN(ITEM_MAX_COUNT - item->GetCount(), bCount);
- bCount -= bCount2;
- item->SetCount(item->GetCount() + bCount2);
- if (bCount == 0)
- {
- if (bMsg)
- ChatPacket(CHAT_TYPE_INFO, ("Obiectul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
- return item;
- }
- }
- }
- }
- else if (p->bType == ITEM_METIN && p->bSubType == METIN_NORMAL) //stone item
- {
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item = GetStoneInventoryItem(i);
- if (!item)
- continue;
- if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
- {
- if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
- {
- if (bCount < p->alValues[1])
- bCount = p->alValues[1];
- }
- WORD bCount2 = MIN(ITEM_MAX_COUNT - item->GetCount(), bCount);
- bCount -= bCount2;
- item->SetCount(item->GetCount() + bCount2);
- if (bCount == 0)
- {
- if (bMsg)
- ChatPacket(CHAT_TYPE_INFO, ("|cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item->GetName());
- return item;
- }
- }
- }
- }
- else if ((p->bType == ITEM_USE && p->bSubType == USE_ABILITY_UP) || (p->bType == ITEM_USE && p->bSubType == USE_AFFECT) || (p->bType == ITEM_BLEND))//Special items
- {
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item = GetDndInventoryItem(i);
- if (!item)
- continue;
- if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
- {
- if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
- {
- if (bCount < p->alValues[1])
- bCount = p->alValues[1];
- }
- WORD bCount2 = MIN(ITEM_MAX_COUNT - item->GetCount(), bCount);
- bCount -= bCount2;
- item->SetCount(item->GetCount() + bCount2);
- if (bCount == 0)
- {
- if (bMsg)
- ChatPacket(CHAT_TYPE_INFO, ("Cufarul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
- return item;
- }
- }
- }
- }
- else if ((p->bType == ITEM_RESOURCE && p->bSubType == RESOURCE_FISHBONE) || (p->bType == ITEM_USE && p->bSubType == USE_BAIT) || (p->bType == ITEM_FISH && p->bSubType == FISH_ALIVE) || (p->bType == ITEM_FISH && p->bSubType == FISH_DEAD) || (p->bType == ITEM_CAMPFIRE) || (p->bType == ITEM_SPECIAL && p->bSubType == SPECIAL_MAP) || (p->bType == ITEM_USE && p->bSubType == USE_PUT_INTO_ACCESSORY_SOCKET) || (p->bType == ITEM_RESOURCE && p->bSubType == RESOURCE_WATERSTONEPIECE) || (p->bType == ITEM_USE && p->bSubType == USE_ADD_ACCESSORY_SOCKET))//Special items
- {
- for (int i = 0; i < SPECIAL_INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item = GetGearInventoryItem(i);
- if (!item)
- continue;
- if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
- {
- if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
- {
- if (bCount < p->alValues[1])
- bCount = p->alValues[1];
- }
- WORD bCount2 = MIN(ITEM_MAX_COUNT - item->GetCount(), bCount);
- bCount -= bCount2;
- item->SetCount(item->GetCount() + bCount2);
- if (bCount == 0)
- {
- if (bMsg)
- ChatPacket(CHAT_TYPE_INFO, (" |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special! "), item->GetName());
- return item;
- }
- }
- }
- }
- else
- {
- #endif
- for (int i = 0; i < INVENTORY_MAX_NUM; ++i)
- {
- LPITEM item = GetInventoryItem(i);
- if (!item)
- continue;
- #ifdef ENABLE_SORT_INVENTORY
- if (item->GetOriginalVnum() == dwItemVnum && FN_check_item_socket(item))
- #else
- if (item->GetVnum() == dwItemVnum && FN_check_item_socket(item))
- #endif
- {
- if (IS_SET(p->dwFlags, ITEM_FLAG_MAKECOUNT))
- {
- if (bCount < p->alValues[1])
- bCount = p->alValues[1];
- }
- WORD bCount2 = MIN(ITEM_MAX_COUNT - item->GetCount(), bCount);
- bCount -= bCount2;
- item->SetCount(item->GetCount() + bCount2);
- if (bCount == 0)
- {
- if (bMsg)
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Ai primit - %s"), item->GetName()); // Nu
- return item;
- }
- }
- }
- }
- #ifdef ENABLE_SPECIAL_STORAGE
- }
- #endif
- LPITEM item = ITEM_MANAGER::instance().CreateItem(dwItemVnum, bCount, 0, true);
- if (!item)
- {
- sys_err("cannot create item by vnum %u (name: %s)", dwItemVnum, GetName());
- return NULL;
- }
- if (item->GetType() == ITEM_BLEND)
- {
- for (int i=0; i < INVENTORY_MAX_NUM; i++)
- {
- LPITEM inv_item = GetInventoryItem(i);
- if (inv_item == NULL) continue;
- if (inv_item->GetType() == ITEM_BLEND)
- {
- if (inv_item->GetVnum() == item->GetVnum())
- {
- if (inv_item->GetSocket(0) == item->GetSocket(0) &&
- inv_item->GetSocket(1) == item->GetSocket(1) &&
- inv_item->GetSocket(2) == item->GetSocket(2) &&
- inv_item->GetCount() < ITEM_MAX_COUNT)
- {
- inv_item->SetCount(inv_item->GetCount() + item->GetCount());
- // Memory Leak Fix
- M2_DESTROY_ITEM(item);
- return inv_item;
- }
- }
- }
- }
- }
- int iEmptyCell;
- if (item->IsDragonSoul())
- {
- iEmptyCell = GetEmptyDragonSoulInventory(item);
- }
- #ifdef ENABLE_SPECIAL_STORAGE
- else if(item->IsUpgradeItem())
- {
- iEmptyCell = GetEmptyUpgradeInventory(item);
- }
- else if(item->IsBook())
- {
- iEmptyCell = GetEmptyBookInventory(item);
- }
- else if(item->IsStone())
- {
- iEmptyCell = GetEmptyStoneInventory(item);
- }
- else if(item->IsDnd())
- {
- iEmptyCell = GetEmptyDndInventory(item);
- }
- else if(item->IsGear())
- {
- iEmptyCell = GetEmptyGearInventory(item);
- }
- #endif
- else
- iEmptyCell = GetEmptyInventory(item->GetSize());
- if (iEmptyCell != -1)
- {
- if (item->IsDragonSoul())
- item->AddToCharacter(this, TItemPos(DRAGON_SOUL_INVENTORY, iEmptyCell));
- #ifdef ENABLE_SPECIAL_STORAGE
- else if (item->IsUpgradeItem())
- {
- item->AddToCharacter(this, TItemPos(UPGRADE_INVENTORY, iEmptyCell));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Obiectul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
- }
- else if (item->IsBook())
- {
- item->AddToCharacter(this, TItemPos(BOOK_INVENTORY, iEmptyCell));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("|cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item->GetName());
- }
- else if (item->IsStone())
- {
- item->AddToCharacter(this, TItemPos(STONE_INVENTORY, iEmptyCell));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("|cFF47DA00|H|h[%s]|H|h|r a fost adaugata in depozitul special!"), item->GetName());
- }
- else if (item->IsDnd())
- {
- item->AddToCharacter(this, TItemPos(DND_INVENTORY, iEmptyCell));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Cufarul: |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special!"), item->GetName());
- }
- else if (item->IsGear())
- {
- item->AddToCharacter(this, TItemPos(GEAR_INVENTORY, iEmptyCell));
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT(" |cFF47DA00|H|h[%s]|H|h|r a fost adaugat in depozitul special! "), item->GetName());
- }
- #endif
- else
- #ifdef ENABLE_SORT_INVENTORY
- item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell), bWereMine);
- #else
- item->AddToCharacter(this, TItemPos(INVENTORY, iEmptyCell));
- #endif
- LogManager::instance().ItemLog(this, item, "SYSTEM", item->GetName());
- if (item->GetType() == ITEM_USE && item->GetSubType() == USE_POTION)
- {
- TQuickslot * pSlot;
- if (GetQuickslot(0, &pSlot) && pSlot->type == QUICKSLOT_TYPE_NONE)
- {
- TQuickslot slot;
- slot.type = QUICKSLOT_TYPE_ITEM;
- slot.pos = iEmptyCell;
- SetQuickslot(0, slot);
- }
- }
- }
- else
- {
- item->AddToGround(GetMapIndex(), GetXYZ());
- item->StartDestroyEvent();
- if (IS_SET(item->GetAntiFlag(), ITEM_ANTIFLAG_DROP))
- item->SetOwnership(this, 6); //DnD work drop spam 30
- else
- item->SetOwnership(this, 8); //DnD work drop spam 35
- LogManager::instance().ItemLog(this, item, "SYSTEM_DROP", item->GetName());
- }
- sys_log(0,
- "7: %d %d", dwItemVnum, bCount);
- return item;
- }
- bool CHARACTER::GiveItem(LPCHARACTER victim, TItemPos Cell)
- {
- if (!CanHandleItem())
- return false;
- LPITEM item = GetItem(Cell);
- if (item && !item->IsExchanging())
- {
- if (victim->CanReceiveItem(this, item))
- {
- victim->ReceiveItem(this, item);
- return true;
- }
- }
- return false;
- }
- bool CHARACTER::CanReceiveItem(LPCHARACTER from, LPITEM item) const
- {
- if (IsPC())
- return false;
- // TOO_LONG_DISTANCE_EXCHANGE_BUG_FIX
- if (DISTANCE_APPROX(GetX() - from->GetX(), GetY() - from->GetY()) > 2000)
- return false;
- // END_OF_TOO_LONG_DISTANCE_EXCHANGE_BUG_FIX
- switch (GetRaceNum())
- {
- case fishing::CAMPFIRE_MOB:
- if (item->GetType() == ITEM_FISH &&
- (item->GetSubType() == FISH_ALIVE || item->GetSubType() == FISH_DEAD))
- return true;
- break;
- case fishing::FISHER_MOB:
- if (item->GetType() == ITEM_ROD)
- return true;
- break;
- // BUILDING_NPC
- case BLACKSMITH_WEAPON_MOB:
- case DEVILTOWER_BLACKSMITH_WEAPON_MOB:
- if (item->GetType() == ITEM_WEAPON &&
- item->GetRefinedVnum())
- return true;
- else
- return false;
- break;
- case BLACKSMITH_ARMOR_MOB:
- case DEVILTOWER_BLACKSMITH_ARMOR_MOB:
- if (item->GetType() == ITEM_ARMOR &&
- (item->GetSubType() == ARMOR_BODY || item->GetSubType() == ARMOR_SHIELD || item->GetSubType() == ARMOR_HEAD) &&
- item->GetRefinedVnum())
- return true;
- else
- return false;
- break;
- case BLACKSMITH_ACCESSORY_MOB:
- case DEVILTOWER_BLACKSMITH_ACCESSORY_MOB:
- if (item->GetType() == ITEM_ARMOR &&
- !(item->GetSubType() == ARMOR_BODY || item->GetSubType() == ARMOR_SHIELD || item->GetSubType() == ARMOR_HEAD) &&
- item->GetRefinedVnum())
- return true;
- else
- return false;
- break;
- // END_OF_BUILDING_NPC
- case BLACKSMITH_MOB:
- if (item->GetRefinedVnum() && item->GetRefineSet() < 500)
- {
- return true;
- }
- else
- {
- return false;
- }
- case BLACKSMITH2_MOB:
- if (item->GetRefineSet() >= 500)
- {
- return true;
- }
- else
- {
- return false;
- }
- case ALCHEMIST_MOB:
- if (item->GetRefinedVnum())
- return true;
- break;
- case 20101:
- case 20102:
- case 20103:
- // ÃÊ±Þ ¸»
- if (item->GetVnum() == ITEM_REVIVE_HORSE_1)
- {
- if (!IsDead())
- {
- from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti hranii cal mort."));
- return false;
- }
- return true;
- }
- else if (item->GetVnum() == ITEM_HORSE_FOOD_1)
- {
- if (IsDead())
- {
- from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti hranii cal mort."));
- return false;
- }
- return true;
- }
- else if (item->GetVnum() == ITEM_HORSE_FOOD_2 || item->GetVnum() == ITEM_HORSE_FOOD_3)
- {
- return false;
- }
- break;
- case 20104:
- case 20105:
- case 20106:
- // Áß±Þ ¸»
- if (item->GetVnum() == ITEM_REVIVE_HORSE_2)
- {
- if (!IsDead())
- {
- from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti hranii cal mort."));
- return false;
- }
- return true;
- }
- else if (item->GetVnum() == ITEM_HORSE_FOOD_2)
- {
- if (IsDead())
- {
- from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti hranii cal mort."));
- return false;
- }
- return true;
- }
- else if (item->GetVnum() == ITEM_HORSE_FOOD_1 || item->GetVnum() == ITEM_HORSE_FOOD_3)
- {
- return false;
- }
- break;
- case 20107:
- case 20108:
- case 20109:
- // °í±Þ ¸»
- if (item->GetVnum() == ITEM_REVIVE_HORSE_3)
- {
- if (!IsDead())
- {
- from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti hranii cal mort."));
- return false;
- }
- return true;
- }
- else if (item->GetVnum() == ITEM_HORSE_FOOD_3)
- {
- if (IsDead())
- {
- from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti hranii cal mort."));
- return false;
- }
- return true;
- }
- else if (item->GetVnum() == ITEM_HORSE_FOOD_1 || item->GetVnum() == ITEM_HORSE_FOOD_2)
- {
- return false;
- }
- break;
- }
- //if (IS_SET(item->GetFlag(), ITEM_FLAG_QUEST_GIVE))
- {
- return true;
- }
- return false;
- }
- void CHARACTER::ReceiveItem(LPCHARACTER from, LPITEM item)
- {
- if (IsPC())
- return;
- switch (GetRaceNum())
- {
- case fishing::CAMPFIRE_MOB:
- if (item->GetType() == ITEM_FISH && (item->GetSubType() == FISH_ALIVE || item->GetSubType() == FISH_DEAD))
- fishing::Grill(from, item);
- else
- {
- // TAKE_ITEM_BUG_FIX
- from->SetQuestNPCID(GetVID());
- // END_OF_TAKE_ITEM_BUG_FIX
- quest::CQuestManager::instance().TakeItem(from->GetPlayerID(), GetRaceNum(), item);
- }
- break;
- // DEVILTOWER_NPC
- case DEVILTOWER_BLACKSMITH_WEAPON_MOB:
- case DEVILTOWER_BLACKSMITH_ARMOR_MOB:
- case DEVILTOWER_BLACKSMITH_ACCESSORY_MOB:
- if (item->GetRefinedVnum() != 0 && item->GetRefineSet() != 0 && item->GetRefineSet() < 500)
- {
- from->SetRefineNPC(this);
- from->RefineInformation(item->GetCell(), REFINE_TYPE_MONEY_ONLY);
- }
- else
- {
- from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti urca nivelul itemului actual."));
- }
- break;
- // END_OF_DEVILTOWER_NPC
- case BLACKSMITH_MOB:
- case BLACKSMITH2_MOB:
- case BLACKSMITH_WEAPON_MOB:
- case BLACKSMITH_ARMOR_MOB:
- case BLACKSMITH_ACCESSORY_MOB:
- if (item->GetRefinedVnum())
- {
- from->SetRefineNPC(this);
- from->RefineInformation(item->GetCell(), REFINE_TYPE_NORMAL);
- }
- else
- {
- from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Acest element nu poate fi imbunatatit."));
- }
- break;
- case 20101:
- case 20102:
- case 20103:
- case 20104:
- case 20105:
- case 20106:
- case 20107:
- case 20108:
- case 20109:
- if (item->GetVnum() == ITEM_REVIVE_HORSE_1 ||
- item->GetVnum() == ITEM_REVIVE_HORSE_2 ||
- item->GetVnum() == ITEM_REVIVE_HORSE_3)
- {
- from->ReviveHorse();
- item->SetCount(item->GetCount()-1);
- from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Calul tau este intr-o conditie perfecta !"));
- }
- else if (item->GetVnum() == ITEM_HORSE_FOOD_1 ||
- item->GetVnum() == ITEM_HORSE_FOOD_2 ||
- item->GetVnum() == ITEM_HORSE_FOOD_3)
- {
- from->FeedHorse();
- from->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Calul tau trebuie hranit."));
- item->SetCount(item->GetCount()-1);
- EffectPacket(SE_HPUP_RED);
- }
- break;
- default:
- sys_log(0, "TakeItem %s %d %s", from->GetName(), GetRaceNum(), item->GetName());
- from->SetQuestNPCID(GetVID());
- quest::CQuestManager::instance().TakeItem(from->GetPlayerID(), GetRaceNum(), item);
- break;
- }
- }
- bool CHARACTER::IsEquipUniqueItem(DWORD dwItemVnum) const
- {
- {
- LPITEM u = GetWear(WEAR_UNIQUE1);
- if (u && u->GetVnum() == dwItemVnum)
- return true;
- }
- {
- LPITEM u = GetWear(WEAR_UNIQUE2);
- if (u && u->GetVnum() == dwItemVnum)
- return true;
- }
- {
- LPITEM u = GetWear(WEAR_COSTUME_MOUNT);
- if (u && u->GetVnum() == dwItemVnum)
- return true;
- }
- if (dwItemVnum == UNIQUE_ITEM_RING_OF_LANGUAGE)
- return IsEquipUniqueItem(UNIQUE_ITEM_RING_OF_LANGUAGE_SAMPLE);
- return false;
- }
- // CHECK_UNIQUE_GROUP
- bool CHARACTER::IsEquipUniqueGroup(DWORD dwGroupVnum) const
- {
- {
- LPITEM u = GetWear(WEAR_UNIQUE1);
- if (u && u->GetSpecialGroup() == (int)dwGroupVnum)
- return true;
- }
- {
- LPITEM u = GetWear(WEAR_UNIQUE2);
- if (u && u->GetSpecialGroup() == (int)dwGroupVnum)
- return true;
- }
- {
- LPITEM u = GetWear(WEAR_COSTUME_MOUNT);
- if (u && u->GetSpecialGroup() == (int)dwGroupVnum)
- return true;
- }
- return false;
- }
- // END_OF_CHECK_UNIQUE_GROUP
- void CHARACTER::SetRefineMode(int iAdditionalCell)
- {
- m_iRefineAdditionalCell = iAdditionalCell;
- m_bUnderRefine = true;
- }
- void CHARACTER::ClearRefineMode()
- {
- m_bUnderRefine = false;
- SetRefineNPC( NULL );
- }
- bool CHARACTER::GiveItemFromSpecialItemGroup(DWORD dwGroupNum, std::vector<DWORD> &dwItemVnums,
- std::vector<DWORD> &dwItemCounts, std::vector <LPITEM> &item_gets, int &count)
- {
- const CSpecialItemGroup* pGroup = ITEM_MANAGER::instance().GetSpecialItemGroup(dwGroupNum);
- if (!pGroup)
- {
- sys_err("cannot find special item group %d", dwGroupNum);
- return false;
- }
- std::vector <int> idxes;
- int n = pGroup->GetMultiIndex(idxes);
- bool bSuccess;
- for (int i = 0; i < n; i++)
- {
- bSuccess = false;
- int idx = idxes[i];
- DWORD dwVnum = pGroup->GetVnum(idx);
- DWORD dwCount = pGroup->GetCount(idx);
- int iRarePct = pGroup->GetRarePct(idx);
- LPITEM item_get = NULL;
- switch (dwVnum)
- {
- case CSpecialItemGroup::GOLD:
- PointChange(POINT_GOLD, dwCount);
- LogManager::instance().CharLog(this, dwCount, "TREASURE_GOLD", "");
- bSuccess = true;
- break;
- case CSpecialItemGroup::EXP:
- {
- PointChange(POINT_EXP, dwCount);
- LogManager::instance().CharLog(this, dwCount, "TREASURE_EXP", "");
- bSuccess = true;
- }
- break;
- case CSpecialItemGroup::MOB:
- {
- sys_log(0, "CSpecialItemGroup::MOB %d", dwCount);
- int x = GetX() + number(-500, 500);
- int y = GetY() + number(-500, 500);
- LPCHARACTER ch = CHARACTER_MANAGER::instance().SpawnMob(dwCount, GetMapIndex(), x, y, 0, true, -1);
- if (ch)
- ch->SetAggressive();
- bSuccess = true;
- }
- break;
- case CSpecialItemGroup::SLOW:
- {
- sys_log(0, "CSpecialItemGroup::SLOW %d", -(int)dwCount);
- AddAffect(AFFECT_SLOW, POINT_MOV_SPEED, -(int)dwCount, AFF_SLOW, 300, 0, true);
- bSuccess = true;
- }
- break;
- case CSpecialItemGroup::DRAIN_HP:
- {
- int iDropHP = GetMaxHP()*dwCount/100;
- sys_log(0, "CSpecialItemGroup::DRAIN_HP %d", -iDropHP);
- iDropHP = MIN(iDropHP, GetHP()-1);
- sys_log(0, "CSpecialItemGroup::DRAIN_HP %d", -iDropHP);
- PointChange(POINT_HP, -iDropHP);
- bSuccess = true;
- }
- break;
- case CSpecialItemGroup::POISON:
- {
- AttackedByPoison(NULL);
- bSuccess = true;
- }
- break;
- case CSpecialItemGroup::MOB_GROUP:
- {
- int sx = GetX() - number(300, 500);
- int sy = GetY() - number(300, 500);
- int ex = GetX() + number(300, 500);
- int ey = GetY() + number(300, 500);
- CHARACTER_MANAGER::instance().SpawnGroup(dwCount, GetMapIndex(), sx, sy, ex, ey, NULL, true);
- bSuccess = true;
- }
- break;
- default:
- {
- item_get = AutoGiveItem(dwVnum, dwCount, iRarePct);
- if (item_get)
- {
- bSuccess = true;
- }
- }
- break;
- }
- if (bSuccess)
- {
- dwItemVnums.push_back(dwVnum);
- dwItemCounts.push_back(dwCount);
- item_gets.push_back(item_get);
- count++;
- }
- else
- {
- return false;
- }
- }
- return bSuccess;
- }
- // NEW_HAIR_STYLE_ADD
- bool CHARACTER::ItemProcess_Hair(LPITEM item, int iDestCell)
- {
- if (item->CheckItemUseLevel(GetLevel()) == false)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asta."));
- return false;
- }
- DWORD hair = item->GetVnum();
- switch (GetJob())
- {
- case JOB_WARRIOR :
- hair -= 72000; // 73001 - 72000 = 1001 ºÎÅÍ Çì¾î ¹øÈ£ ½ÃÀÛ
- break;
- case JOB_ASSASSIN :
- hair -= 71250;
- break;
- case JOB_SURA :
- hair -= 70500;
- break;
- case JOB_SHAMAN :
- hair -= 69750;
- break;
- default :
- return false;
- break;
- }
- if (hair == GetPart(PART_HAIR))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asta."));
- return true;
- }
- item->SetCount(item->GetCount() - 1);
- SetPart(PART_HAIR, hair);
- UpdatePacket();
- return true;
- }
- // END_NEW_HAIR_STYLE_ADD
- bool CHARACTER::ItemProcess_Polymorph(LPITEM item)
- {
- if (IsPolymorphed())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Esti deja transformat."));
- return false;
- }
- if (true == IsRiding())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu te poti transforma calare."));
- return false;
- }
- DWORD dwVnum = item->GetSocket(0);
- if (dwVnum == 0)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti citii aceasta carte."));
- item->SetCount(item->GetCount()-1);
- return false;
- }
- const CMob* pMob = CMobManager::instance().Get(dwVnum);
- if (pMob == NULL)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti citii aceasta carte."));
- item->SetCount(item->GetCount()-1);
- return false;
- }
- switch (item->GetVnum())
- {
- case 70104 :
- case 70105 :
- case 70106 :
- case 70107 :
- case 71093 :
- {
- sys_log(0, "USE_POLYMORPH_BALL PID(%d) vnum(%d)", GetPlayerID(), dwVnum);
- int iPolymorphLevelLimit = MAX(0, 20 - GetLevel() * 3 / 10);
- if (pMob->m_table.bLevel >= GetLevel() + iPolymorphLevelLimit)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu te poti transforma."));
- return false;
- }
- int iDuration = GetSkillLevel(POLYMORPH_SKILL_ID) == 0 ? 5 : (5 + (5 + GetSkillLevel(POLYMORPH_SKILL_ID)/40 * 25));
- iDuration *= 60;
- DWORD dwBonus = 0;
- if (true == LC_IsYMIR() || true == LC_IsKorea())
- {
- dwBonus = GetSkillLevel(POLYMORPH_SKILL_ID) + 60;
- }
- else
- {
- dwBonus = (2 + GetSkillLevel(POLYMORPH_SKILL_ID)/40) * 100;
- }
- AddAffect(AFFECT_POLYMORPH, POINT_POLYMORPH, dwVnum, AFF_POLYMORPH, iDuration, 0, true);
- AddAffect(AFFECT_POLYMORPH, POINT_ATT_BONUS, dwBonus, AFF_POLYMORPH, iDuration, 0, false);
- item->SetCount(item->GetCount()-1);
- }
- break;
- case 50322:
- {
- sys_log(0, "USE_POLYMORPH_BOOK: %s(%u) vnum(%u)", GetName(), GetPlayerID(), dwVnum);
- if (CPolymorphUtils::instance().PolymorphCharacter(this, item, pMob) == true)
- {
- CPolymorphUtils::instance().UpdateBookPracticeGrade(this, item);
- }
- else
- {
- }
- }
- break;
- default :
- sys_err("POLYMORPH invalid item passed PID(%d) vnum(%d)", GetPlayerID(), item->GetOriginalVnum());
- return false;
- }
- return true;
- }
- bool CHARACTER::CanDoCube() const
- {
- if (m_bIsObserver) return false;
- if (GetShop()) return false;
- if (GetMyShop()) return false;
- if (m_bUnderRefine) return false;
- if (IsWarping()) return false;
- return true;
- }
- bool CHARACTER::UnEquipSpecialRideUniqueItem()
- {
- LPITEM Unique1 = GetWear(WEAR_UNIQUE1);
- LPITEM Unique2 = GetWear(WEAR_UNIQUE2);
- LPITEM Unique3 = GetWear(WEAR_COSTUME_MOUNT);
- if (NULL != Unique1)
- {
- if (UNIQUE_GROUP_SPECIAL_RIDE == Unique1->GetSpecialGroup())
- {
- return UnequipItem(Unique1);
- }
- }
- if (NULL != Unique2)
- {
- if (UNIQUE_GROUP_SPECIAL_RIDE == Unique2->GetSpecialGroup())
- {
- return UnequipItem(Unique2);
- }
- }
- if (NULL != Unique3)
- {
- if (UNIQUE_GROUP_SPECIAL_RIDE == Unique3->GetSpecialGroup())
- {
- return UnequipItem(Unique3);
- }
- }
- return true;
- }
- void CHARACTER::AutoRecoveryItemProcess(const EAffectTypes type)
- {
- if (true == IsDead() || true == IsStun())
- return;
- if (false == IsPC())
- return;
- if (AFFECT_AUTO_HP_RECOVERY != type && AFFECT_AUTO_SP_RECOVERY != type)
- return;
- if (NULL != FindAffect(AFFECT_STUN))
- return;
- {
- const DWORD stunSkills[] = { SKILL_TANHWAN, SKILL_GEOMPUNG, SKILL_BYEURAK, SKILL_GIGUNG };
- for (size_t i=0 ; i < sizeof(stunSkills)/sizeof(DWORD) ; ++i)
- {
- const CAffect* p = FindAffect(stunSkills[i]);
- if (NULL != p && AFF_STUN == p->dwFlag)
- return;
- }
- }
- const CAffect* pAffect = FindAffect(type);
- const size_t idx_of_amount_of_used = 1;
- const size_t idx_of_amount_of_full = 2;
- if (NULL != pAffect)
- {
- LPITEM pItem = FindItemByID(pAffect->dwFlag);
- if (NULL != pItem && true == pItem->GetSocket(0))
- {
- if (false == CArenaManager::instance().IsArenaMap(GetMapIndex()))
- {
- const long amount_of_used = pItem->GetSocket(idx_of_amount_of_used);
- const long amount_of_full = pItem->GetSocket(idx_of_amount_of_full);
- const int32_t avail = amount_of_full - amount_of_used;
- int32_t amount = 0;
- if (AFFECT_AUTO_HP_RECOVERY == type)
- {
- amount = GetMaxHP() - (GetHP() + GetPoint(POINT_HP_RECOVERY));
- }
- else if (AFFECT_AUTO_SP_RECOVERY == type)
- {
- amount = GetMaxSP() - (GetSP() + GetPoint(POINT_SP_RECOVERY));
- }
- if (amount > 0)
- {
- if (avail > amount)
- {
- const int pct_of_used = amount_of_used * 100 / amount_of_full;
- const int pct_of_will_used = (amount_of_used + amount) * 100 / amount_of_full;
- bool bLog = false;
- if ((pct_of_will_used / 10) - (pct_of_used / 10) >= 1)
- bLog = true;
- pItem->SetSocket(idx_of_amount_of_used, amount_of_used + amount, bLog);
- }
- else
- {
- amount = avail;
- ITEM_MANAGER::instance().RemoveItem( pItem );
- }
- if (AFFECT_AUTO_HP_RECOVERY == type)
- {
- PointChange( POINT_HP_RECOVERY, amount );
- EffectPacket( SE_AUTO_HPUP );
- }
- else if (AFFECT_AUTO_SP_RECOVERY == type)
- {
- PointChange( POINT_SP_RECOVERY, amount );
- EffectPacket( SE_AUTO_SPUP );
- }
- }
- }
- else
- {
- pItem->Lock(false);
- pItem->SetSocket(0, false);
- RemoveAffect( const_cast<CAffect*>(pAffect) );
- }
- }
- else
- {
- RemoveAffect( const_cast<CAffect*>(pAffect) );
- }
- }
- }
- bool CHARACTER::IsValidItemPosition(TItemPos Pos) const
- {
- BYTE window_type = Pos.window_type;
- WORD cell = Pos.cell;
- switch (window_type)
- {
- case RESERVED_WINDOW:
- return false;
- case INVENTORY:
- case EQUIPMENT:
- return cell < (INVENTORY_AND_EQUIP_SLOT_MAX);
- case DRAGON_SOUL_INVENTORY:
- return cell < (DRAGON_SOUL_INVENTORY_MAX_NUM);
- #ifdef ENABLE_SPECIAL_STORAGE
- case UPGRADE_INVENTORY:
- case BOOK_INVENTORY:
- case STONE_INVENTORY:
- case DND_INVENTORY:
- case GEAR_INVENTORY:
- return cell < (SPECIAL_INVENTORY_MAX_NUM);
- #endif
- case SAFEBOX:
- if (NULL != m_pkSafebox)
- return m_pkSafebox->IsValidPosition(cell);
- else
- return false;
- case MALL:
- if (NULL != m_pkMall)
- return m_pkMall->IsValidPosition(cell);
- else
- return false;
- #ifdef __ATTR_SWITCH_SYSTEM__
- case SWITCHBOT:
- return cell < SWITCHBOT_SLOT_COUNT;
- #endif
- default:
- return false;
- }
- }
- #define VERIFY_MSG(exp, msg) \
- if (true == (exp)) { \
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT(msg)); \
- return false; \
- }
- bool CHARACTER::CanEquipNow(const LPITEM item, const TItemPos& srcCell, const TItemPos& destCell) /*const*/
- {
- const TItemTable* itemTable = item->GetProto();
- BYTE itemType = item->GetType();
- BYTE itemSubType = item->GetSubType();
- #ifdef __WEAPON_COSTUME_SYSTEM__
- if (item->GetType() == ITEM_WEAPON && item->GetSubType() != WEAPON_ARROW)
- {
- LPITEM pkItem = GetWear(WEAR_COSTUME_WEAPON);
- if (pkItem)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("For can do this unwear the costume weapon."));
- return false;
- }
- }
- else if (item->GetType() == ITEM_COSTUME && item->GetSubType() == COSTUME_WEAPON)
- {
- LPITEM pkItem = GetWear(WEAR_WEAPON);
- if (!pkItem)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't wear a costume weapon without have a weapon weared."));
- return false;
- }
- else if (item->GetValue(3) != pkItem->GetSubType())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't wear a costume weapon who has different type of your weapon."));
- return false;
- }
- else if (pkItem->GetType() == ITEM_ROD || pkItem->GetType() == ITEM_PICK) // // block fish rod and pick
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti pune skin de arma pe undita, esti nebun? :)) "));
- return false;
- }
- }
- #endif
- #ifdef __EFFECT_SYSTEM__
- if (item->GetType() == ITEM_ARMOR && item->GetSubType() == ARMOR_BODY)
- {
- LPITEM pkItem = GetWear(WEAR_EFFECT_ARMOR);
- if (pkItem)
- {
- ChatPacket(CHAT_TYPE_INFO, "Pentru a schimba armura trebuie sa dai effectul jos.");
- return false;
- }
- }
- else if (item->GetType() == ITEM_COSTUME && item->GetSubType() == USE_EFFECT)
- {
- {
- LPITEM pkItem = GetWear(WEAR_BODY);
- if (!pkItem)
- {
- ChatPacket(CHAT_TYPE_INFO, "Trebuie sa ai o armura echipata pentru a purta effectul.");
- return false;
- }
- }
- }
- if (item->GetType() == ITEM_WEAPON && item->GetSubType() != WEAPON_ARROW)
- {
- LPITEM pkItem = GetWear(WEAR_EFFECT_WEAPON);
- if (pkItem)
- {
- ChatPacket(CHAT_TYPE_INFO, "Pentru a schimba arma trebuie sa dai effectul jos.");
- return false;
- }
- }
- else if (item->GetType() == ITEM_COSTUME && item->GetSubType() == USE_EFFECT_TWO)
- {
- LPITEM pkItem = GetWear(WEAR_WEAPON);
- if (!pkItem)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Trebuie sa ai o arma echipata pentru a purta effectul."));
- return false;
- }
- }
- #endif
- switch (GetJob())
- {
- case JOB_WARRIOR:
- if (item->GetAntiFlag() & ITEM_ANTIFLAG_WARRIOR)
- return false;
- break;
- case JOB_ASSASSIN:
- if (item->GetAntiFlag() & ITEM_ANTIFLAG_ASSASSIN)
- return false;
- break;
- case JOB_SHAMAN:
- if (item->GetAntiFlag() & ITEM_ANTIFLAG_SHAMAN)
- return false;
- break;
- case JOB_SURA:
- if (item->GetAntiFlag() & ITEM_ANTIFLAG_SURA)
- return false;
- break;
- }
- for (int i = 0; i < ITEM_LIMIT_MAX_NUM; ++i)
- {
- long limit = itemTable->aLimits[i].lValue;
- switch (itemTable->aLimits[i].bType)
- {
- case LIMIT_LEVEL:
- if (GetLevel() < limit)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nivelul tau este prea mic."));
- return false;
- }
- break;
- case LIMIT_STR:
- if (GetPoint(POINT_ST) < limit)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can not wear."));
- return false;
- }
- break;
- case LIMIT_INT:
- if (GetPoint(POINT_IQ) < limit)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can not wear."));
- return false;
- }
- break;
- case LIMIT_DEX:
- if (GetPoint(POINT_DX) < limit)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can not wear."));
- return false;
- }
- break;
- case LIMIT_CON:
- if (GetPoint(POINT_HT) < limit)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can not wear."));
- return false;
- }
- break;
- }
- }
- if (item->GetWearFlag() & WEARABLE_UNIQUE)
- {
- if ((GetWear(WEAR_UNIQUE1) && GetWear(WEAR_UNIQUE1)->IsSameSpecialGroup(item)) ||
- (GetWear(WEAR_UNIQUE2) && GetWear(WEAR_UNIQUE2)->IsSameSpecialGroup(item)) ||
- (GetWear(WEAR_COSTUME_MOUNT) && GetWear(WEAR_COSTUME_MOUNT)->IsSameSpecialGroup(item)))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti face asa ceva!"));
- return false;
- }
- if (marriage::CManager::instance().IsMarriageUniqueItem(item->GetVnum()) &&
- !marriage::CManager::instance().IsMarried(GetPlayerID()))
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Puteti folosi acest item doar in prezenta partenerului."));
- return false;
- }
- }
- if (item->GetType() == ITEM_RING) // ring check for two same rings
- {
- LPITEM ringItems[2] = { GetWear(WEAR_RING1), GetWear(WEAR_RING2) };
- for (int i = 0; i < 2; i++)
- {
- if (ringItems[i]) // if that item is equipped
- {
- if (ringItems[i]->GetVnum() == item->GetVnum())
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nu poti echipa acest item de doua ori!"));
- return false;
- }
- }
- }
- }
- return true;
- }
- bool CHARACTER::CanUnequipNow(const LPITEM item, const TItemPos& srcCell, const TItemPos& destCell) /*const*/
- {
- #ifdef BELT_INVENTORY_FIX
- if (ITEM_BELT == item->GetType())
- VERIFY_MSG(CBeltInventoryHelper::IsExistItemInBeltInventory(this), "<Belt>Elibereaza mai intai inventarul Belt.");
- #endif
- // ¿µ¿øÈ÷ ÇØÁ¦ÇÒ ¼ö ¾ø´Â ¾ÆÀÌÅÛ
- if (IS_SET(item->GetFlag(), ITEM_FLAG_IRREMOVABLE))
- return false;
- #ifdef __EFFECT_SYSTEM__
- if (item->GetType() == ITEM_ARMOR && item->GetSubType() == ARMOR_BODY)
- {
- LPITEM pkItem = GetWear(WEAR_EFFECT_ARMOR);
- if (pkItem)
- {
- ChatPacket(CHAT_TYPE_INFO, "Dezachipeaza effectul armurii mai intai.");
- return false;
- }
- }
- if (item->GetType() == ITEM_WEAPON && item->GetSubType() != WEAPON_ARROW)
- {
- LPITEM pkItem = GetWear(WEAR_EFFECT_WEAPON);
- if (pkItem)
- {
- ChatPacket(CHAT_TYPE_INFO, "Dezachipeaza effectul armei mai intai.");
- return false;
- }
- }
- #endif
- #ifdef __WEAPON_COSTUME_SYSTEM__
- if (item->GetType() == ITEM_WEAPON && item->GetSubType() != WEAPON_ARROW)
- {
- LPITEM pkItem = GetWear(WEAR_COSTUME_WEAPON);
- if (pkItem)
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("For can do this unwear the costume weapon."));
- return false;
- }
- }
- #endif
- {
- int pos = -1;
- if (item->IsDragonSoul())
- pos = GetEmptyDragonSoulInventory(item);
- #ifdef ENABLE_SPECIAL_STORAGE
- else if (item->IsBook())
- pos = GetEmptyBookInventory(item);
- else if (item->IsUpgradeItem())
- pos = GetEmptyUpgradeInventory(item);
- else if (item->IsStone())
- pos = GetEmptyStoneInventory(item);
- else if (item->IsDnd())
- pos = GetEmptyDndInventory(item);
- else if (item->IsGear())
- pos = GetEmptyGearInventory(item);
- #endif
- else
- pos = GetEmptyInventory(item->GetSize());
- VERIFY_MSG(-1 == pos, "¼ÒÁöǰ¿¡ ºó °ø°£ÀÌ ¾ø½À´Ï´Ù.");
- }
- return true;
- }
Add Comment
Please, Sign In to add comment