Move git root from Client/ to src/ to track all source code: - Client: Game client source (moved to Client/Client/) - Server: Game server source - GameTools: Development tools - CryptoSource: Encryption utilities - database: Database scripts - Script: Game scripts - rylCoder_16.02.2008_src: Legacy coder tools - GMFont, Game: Additional resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
600 lines
18 KiB
C++
600 lines
18 KiB
C++
// ItemInstance.cpp: implementation of the CItemInstance class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#include "ClientMain.h"
|
|
#include "resource.h"
|
|
#include "ItemInstance.h"
|
|
#include "ItemStorage.h"
|
|
#include "WinInput.h"
|
|
#include "GUITooltipItem.h"
|
|
#include "GUITooltipManager.h"
|
|
#include "FrameTimer.h"
|
|
|
|
#include "Item\ItemMgr.h"
|
|
#include "Item\ItemFactory.h"
|
|
#include "Skill\SkillMgr.h"
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
// Construction/Destruction
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
CItemInstance::CItemInstance()
|
|
{
|
|
m_lpItemBase = NULL;
|
|
// m_lpProtoTypeInfo = NULL;
|
|
m_lpSprite = NULL;
|
|
m_lpTooltip = NULL;
|
|
|
|
m_lCoolDownTime = 0;
|
|
m_lCoolDownTimeCount = 0;
|
|
|
|
m_bClassSkill = FALSE;
|
|
m_bSkill = FALSE;
|
|
m_bTradeItem = FALSE;
|
|
m_bShowTooltip = TRUE;
|
|
m_bCanUsed = TRUE;
|
|
m_cCountCooldown = 0;
|
|
m_wGrade = 0;
|
|
|
|
m_wPutX = 0;
|
|
m_wPutY = 0;
|
|
|
|
for(int i = 0; i < 10; i++)
|
|
{
|
|
m_pCoolDownVertices[i].Diffuse.c = 0xFFFFFFFF;
|
|
m_pCoolDownVertices[i].Diffuse.a = 0x80;
|
|
m_pCoolDownVertices[i].Specular.c = 0;
|
|
m_pCoolDownVertices[i].w = 0.1f;
|
|
m_pCoolDownVertices[i].v.z = 0.1f;
|
|
m_pCoolDownVertices[i].tu = 0.0f;
|
|
m_pCoolDownVertices[i].tv = 0.0f;
|
|
}
|
|
|
|
m_wCoolDownIndex[ 0] = 0; m_wCoolDownIndex[ 1] = 1; m_wCoolDownIndex[ 2] = 9;
|
|
m_wCoolDownIndex[ 3] = 1; m_wCoolDownIndex[ 4] = 2; m_wCoolDownIndex[ 5] = 9;
|
|
m_wCoolDownIndex[ 6] = 2; m_wCoolDownIndex[ 7] = 3; m_wCoolDownIndex[ 8] = 9;
|
|
m_wCoolDownIndex[ 9] = 3; m_wCoolDownIndex[10] = 4; m_wCoolDownIndex[11] = 9;
|
|
m_wCoolDownIndex[12] = 4; m_wCoolDownIndex[13] = 5; m_wCoolDownIndex[14] = 9;
|
|
m_wCoolDownIndex[15] = 5; m_wCoolDownIndex[16] = 6; m_wCoolDownIndex[17] = 9;
|
|
m_wCoolDownIndex[18] = 6; m_wCoolDownIndex[19] = 7; m_wCoolDownIndex[20] = 9;
|
|
m_wCoolDownIndex[21] = 7; m_wCoolDownIndex[22] = 8; m_wCoolDownIndex[23] = 9;
|
|
}
|
|
|
|
CItemInstance::~CItemInstance()
|
|
{
|
|
if(m_lpItemBase) { delete m_lpItemBase; m_lpItemBase = NULL; }
|
|
/* if(m_lpProtoTypeInfo)
|
|
{
|
|
if(m_bSkill)
|
|
delete m_lpProtoTypeInfo;
|
|
|
|
m_lpProtoTypeInfo = NULL;
|
|
}*/
|
|
if(m_lpSprite) { delete m_lpSprite; m_lpSprite = NULL; }
|
|
if(m_lpTooltip) { delete m_lpTooltip; m_lpTooltip = NULL; }
|
|
}
|
|
|
|
void CItemInstance::Render(LPDIRECT3DDEVICE8 lpD3DDevice)
|
|
{
|
|
if(!m_lpSprite->m_lpTexture)
|
|
{
|
|
if(m_bSkill)
|
|
{
|
|
// m_lpSprite->m_lpTexture = g_ItemStorage.GetSkillTexture(m_lpProtoTypeInfo->m_SpriteInfo.m_szSpriteName);
|
|
m_lpSprite->m_lpTexture = g_ItemStorage.GetSkillTexture(GetItemInfo().m_SpriteData.m_szSpriteName);
|
|
} else
|
|
{
|
|
// m_lpSprite->m_lpTexture = g_ItemStorage.GetItemTexture(m_lpProtoTypeInfo->m_SpriteInfo.m_szSpriteName);
|
|
m_lpSprite->m_lpTexture = g_ItemStorage.GetItemTexture(GetItemInfo().m_SpriteData.m_szSpriteName);
|
|
}
|
|
}
|
|
|
|
m_lpSprite->Render(lpD3DDevice, 0xFF, m_wPutX, m_wPutY);
|
|
|
|
if(m_lpItemBase->GetEnableStack() && GetNowDurability() > 1)
|
|
{
|
|
unsigned short wPutX, wPutY;
|
|
if(GetItemPos() == ClientSocket::ItemPos_QSlot)
|
|
{
|
|
wPutX = m_wPutX + (m_lpSprite->GetSizeX() / 2) + 16 * GetItemInfo().m_DetailData.m_cXSize - 9;
|
|
wPutY = m_wPutY + (m_lpSprite->GetSizeY() / 2) + 16 * GetItemInfo().m_DetailData.m_cYSize - 11;
|
|
} else
|
|
{
|
|
wPutX = m_wPutX + (m_lpSprite->GetSizeX() / 2) + 13 * GetItemInfo().m_DetailData.m_cXSize - 9;
|
|
wPutY = m_wPutY + (m_lpSprite->GetSizeY() / 2) + 13 * GetItemInfo().m_DetailData.m_cYSize - 11;
|
|
}
|
|
|
|
g_ClientMain.m_lpCommonInterface->RenderStackNumber(lpD3DDevice, wPutX, wPutY, GetNowDurability());
|
|
}
|
|
|
|
/* if(m_bSkill)
|
|
{
|
|
unsigned short wPutX = m_wPutX + 32 - 5;
|
|
unsigned short wPutY = m_wPutY + 32 - 11;
|
|
|
|
g_ClientMain.m_lpCommonInterface->RenderStackNumber(lpD3DDevice, wPutX, wPutY, m_lpItemBase->m_nNowDurability);
|
|
}*/
|
|
|
|
if(m_lCoolDownTimeCount > 0)
|
|
{
|
|
if(GetItemPos() == ClientSocket::ItemPos_QSlot)
|
|
{
|
|
int p = m_lCoolDownTime / 8;
|
|
int m = m_lCoolDownTimeCount / p;
|
|
int n = m_lCoolDownTimeCount % p;
|
|
int jj = 16 * n / p;
|
|
|
|
int nPosX = (m_wPutX + (m_lpSprite->GetSizeX() / 2.0f) - 16);
|
|
int nPosY = (m_wPutY + (m_lpSprite->GetSizeY() / 2.0f) - 16);
|
|
switch(m)
|
|
{
|
|
case 0:
|
|
m_pCoolDownVertices[7].v.x = nPosX + 16 - jj - 0.5f;
|
|
m_pCoolDownVertices[7].v.y = nPosY - 0.5f;
|
|
break;
|
|
|
|
case 1:
|
|
m_pCoolDownVertices[6].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[6].v.y = nPosY + jj - 0.5f;
|
|
|
|
m_pCoolDownVertices[7].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[7].v.y = nPosY - 0.5f;
|
|
break;
|
|
|
|
case 2:
|
|
m_pCoolDownVertices[5].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[5].v.y = nPosY + 16 + jj - 0.5f;
|
|
|
|
m_pCoolDownVertices[6].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[6].v.y = nPosY + 16 - 0.5f;
|
|
m_pCoolDownVertices[7].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[7].v.y = nPosY - 0.5f;
|
|
break;
|
|
|
|
case 3:
|
|
m_pCoolDownVertices[4].v.x = nPosX + jj - 0.5f;
|
|
m_pCoolDownVertices[4].v.y = nPosY + 32 - 0.5f;
|
|
|
|
m_pCoolDownVertices[5].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[5].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[6].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[6].v.y = nPosY + 16 - 0.5f;
|
|
m_pCoolDownVertices[7].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[7].v.y = nPosY - 0.5f;
|
|
break;
|
|
|
|
case 4:
|
|
m_pCoolDownVertices[3].v.x = nPosX + 16 + jj - 0.5f;
|
|
m_pCoolDownVertices[3].v.y = nPosY + 32 - 0.5f;
|
|
|
|
m_pCoolDownVertices[4].v.x = nPosX + 16 - 0.5f;
|
|
m_pCoolDownVertices[4].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[5].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[5].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[6].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[6].v.y = nPosY + 16 - 0.5f;
|
|
m_pCoolDownVertices[7].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[7].v.y = nPosY - 0.5f;
|
|
break;
|
|
|
|
case 5:
|
|
m_pCoolDownVertices[2].v.x = nPosX + 32 - 0.5f;
|
|
m_pCoolDownVertices[2].v.y = nPosY + 32 - jj - 0.5f;
|
|
|
|
m_pCoolDownVertices[3].v.x = nPosX + 32 - 0.5f;
|
|
m_pCoolDownVertices[3].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[4].v.x = nPosX + 16 - 0.5f;
|
|
m_pCoolDownVertices[4].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[5].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[5].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[6].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[6].v.y = nPosY + 16 - 0.5f;
|
|
m_pCoolDownVertices[7].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[7].v.y = nPosY - 0.5f;
|
|
break;
|
|
|
|
case 6:
|
|
m_pCoolDownVertices[1].v.x = nPosX + 32 - 0.5f;
|
|
m_pCoolDownVertices[1].v.y = nPosY + 16 - jj - 0.5f;
|
|
|
|
m_pCoolDownVertices[2].v.x = nPosX + 32 - 0.5f;
|
|
m_pCoolDownVertices[2].v.y = nPosY + 16 - 0.5f;
|
|
m_pCoolDownVertices[3].v.x = nPosX + 32 - 0.5f;
|
|
m_pCoolDownVertices[3].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[4].v.x = nPosX + 16 - 0.5f;
|
|
m_pCoolDownVertices[4].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[5].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[5].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[6].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[6].v.y = nPosY + 16 - 0.5f;
|
|
m_pCoolDownVertices[7].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[7].v.y = nPosY - 0.5f;
|
|
break;
|
|
|
|
case 7:
|
|
m_pCoolDownVertices[0].v.x = nPosX + 32 - jj - 0.5f;
|
|
m_pCoolDownVertices[0].v.y = nPosY - 0.5f;
|
|
|
|
m_pCoolDownVertices[1].v.x = nPosX + 32 - 0.5f;
|
|
m_pCoolDownVertices[1].v.y = nPosY - 0.5f;
|
|
m_pCoolDownVertices[2].v.x = nPosX + 32 - 0.5f;
|
|
m_pCoolDownVertices[2].v.y = nPosY + 16 - 0.5f;
|
|
m_pCoolDownVertices[3].v.x = nPosX + 32 - 0.5f;
|
|
m_pCoolDownVertices[3].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[4].v.x = nPosX + 16 - 0.5f;
|
|
m_pCoolDownVertices[4].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[5].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[5].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[6].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[6].v.y = nPosY + 16 - 0.5f;
|
|
m_pCoolDownVertices[7].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[7].v.y = nPosY - 0.5f;
|
|
break;
|
|
|
|
case 8:
|
|
m_pCoolDownVertices[0].v.x = nPosX + 16 - 0.5f;
|
|
m_pCoolDownVertices[0].v.y = nPosY - 0.5f;
|
|
m_pCoolDownVertices[1].v.x = nPosX + 32 - 0.5f;
|
|
m_pCoolDownVertices[1].v.y = nPosY - 0.5f;
|
|
m_pCoolDownVertices[2].v.x = nPosX + 32 - 0.5f;
|
|
m_pCoolDownVertices[2].v.y = nPosY + 16 - 0.5f;
|
|
m_pCoolDownVertices[3].v.x = nPosX + 32 - 0.5f;
|
|
m_pCoolDownVertices[3].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[4].v.x = nPosX + 16 - 0.5f;
|
|
m_pCoolDownVertices[4].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[5].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[5].v.y = nPosY + 32 - 0.5f;
|
|
m_pCoolDownVertices[6].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[6].v.y = nPosY + 16 - 0.5f;
|
|
m_pCoolDownVertices[7].v.x = nPosX - 0.5f;
|
|
m_pCoolDownVertices[7].v.y = nPosY - 0.5f;
|
|
break;
|
|
}
|
|
|
|
m_pCoolDownVertices[8].v.x = nPosX + 16 - 0.5f;
|
|
m_pCoolDownVertices[8].v.y = nPosY - 0.5f;
|
|
m_pCoolDownVertices[9].v.x = nPosX + 16 - 0.5f;
|
|
m_pCoolDownVertices[9].v.y = nPosY + 16 - 0.5f;
|
|
|
|
lpD3DDevice->SetVertexShader(TLVERTEXFVF);
|
|
lpD3DDevice->SetTexture(0, NULL);
|
|
lpD3DDevice->SetTexture(1, NULL);
|
|
long pIndex = 0, pPri = 8;
|
|
if(m < 8)
|
|
{
|
|
pIndex = 7 - m;
|
|
pPri = m + 1;
|
|
}
|
|
|
|
lpD3DDevice->DrawIndexedPrimitiveUP(D3DPT_TRIANGLELIST, pIndex, 10 - pIndex, pPri, &m_wCoolDownIndex[pIndex * 3], D3DFMT_INDEX16, m_pCoolDownVertices, sizeof(TLVertex));
|
|
}/* else
|
|
{
|
|
}*/
|
|
}
|
|
|
|
if(m_bShowTooltip && m_lpTooltip && IsOverMouse())
|
|
{
|
|
g_TooltipManager.m_ttRenderTarget = m_lpTooltip;
|
|
}
|
|
}
|
|
|
|
BOOL CItemInstance::IsOverMouse(void)
|
|
{
|
|
if(g_DeviceInput.InRect(m_wPutX, m_wPutY, m_wPutX + m_lpSprite->GetSizeX(), m_wPutY + m_lpSprite->GetSizeY()))
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
int CItemInstance::SetItemInfo(const char* lpSerializedItem_In, size_t& nParseLength_InOut)
|
|
{
|
|
int nDBSize = nParseLength_InOut;
|
|
m_lpItemBase = Item::CItemFactory::GetInstance().CreateItem(lpSerializedItem_In, nParseLength_InOut);
|
|
if(m_lpItemBase)
|
|
{
|
|
/* if(pItemIndex.m_cIndex != 0x0FFF)
|
|
{
|
|
SetPos(pItemIndex);
|
|
}*/
|
|
|
|
m_ipPreIndex = m_lpItemBase->GetPos();
|
|
m_dwItemUID = m_lpItemBase->GetUID();
|
|
// m_lpProtoTypeInfo = g_ItemMgr.GetProtoTypeInfo(m_lpItemBase->m_usProtoTypeID);
|
|
m_lpSprite = new CSprite;
|
|
m_lpSprite->Create(0, 0, GetItemInfo().m_SpriteData.m_nSpriteMinX,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMinY,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMaxX,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMaxY, NULL);
|
|
m_lpTooltip = new CGUITooltipItem;
|
|
((CGUITooltipItem *)m_lpTooltip)->SetItem(this);
|
|
|
|
if(GetItemType() == Item::CItemType::POTION)
|
|
{
|
|
m_lCoolDownTime = 14000;
|
|
m_lCoolDownTimeCount = g_ClientMain.m_csStatus.m_lPotionCoolDownTime;
|
|
}
|
|
}
|
|
|
|
return nDBSize;
|
|
}
|
|
|
|
int CItemInstance::SetItemInfofromID(unsigned short wProtoTypeID, Item::ItemPos &pItemIndex)
|
|
{
|
|
m_lpItemBase = Item::CItemFactory::GetInstance().CreateItem(wProtoTypeID);
|
|
if(m_lpItemBase)
|
|
{
|
|
m_lpItemBase->GetPos().SetPos(pItemIndex.m_cIndex);
|
|
|
|
SetPos(pItemIndex.m_cIndex);
|
|
SetItemPos(pItemIndex.m_cPos);
|
|
m_ipPreIndex = m_lpItemBase->GetPos();
|
|
/* if(!m_lpItemBase->IsSet(Item::DetailData::EQUIP))
|
|
{
|
|
SetNowDurability(dwDurability);
|
|
}*/
|
|
|
|
m_lpSprite = new CSprite;
|
|
m_lpSprite->Create(0, 0, GetItemInfo().m_SpriteData.m_nSpriteMinX,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMinY,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMaxX,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMaxY, NULL);
|
|
m_lpTooltip = new CGUITooltipItem;
|
|
((CGUITooltipItem *)m_lpTooltip)->SetItem(this);
|
|
|
|
if(GetItemType() == Item::CItemType::POTION)
|
|
{
|
|
m_lCoolDownTime = 14000;
|
|
m_lCoolDownTimeCount = g_ClientMain.m_csStatus.m_lPotionCoolDownTime;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
BOOL CItemInstance::UpdateCoolDownTime()
|
|
{
|
|
if(!m_cCountCooldown)
|
|
{
|
|
float fUpdate = CFrameTimer::GetUpdateTimer(g_ClientMain.m_nShowInterfaceTimerID);
|
|
if(g_CharacterData.m_lstCharData[g_CharacterData.m_nFocusCharacter]->GetChantFlag(27))
|
|
{
|
|
m_lCoolDownTimeCount -= fUpdate;
|
|
}
|
|
else
|
|
{
|
|
m_lCoolDownTimeCount -= fUpdate * 2.0f;
|
|
}
|
|
|
|
if(m_lCoolDownTimeCount <= 0)
|
|
{
|
|
m_lCoolDownTimeCount = 0;
|
|
m_wGrade = 0;
|
|
|
|
return TRUE;
|
|
}
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CItemInstance::SetSkillInfo(unsigned short wSkillID, unsigned char cGrade, unsigned char cLevel, unsigned char cPos, unsigned char cIndex, long lCoolDown)
|
|
{
|
|
const Skill::ProtoType *lpSkillProtoType = g_SkillMgr.GetSkillProtoType(wSkillID);
|
|
|
|
if(lpSkillProtoType)
|
|
{
|
|
lpSkillProtoType = &lpSkillProtoType[cGrade];
|
|
|
|
if(lpSkillProtoType)
|
|
{
|
|
m_bSkill = TRUE;
|
|
|
|
if(lpSkillProtoType->m_bIsClassSkill) m_bClassSkill = TRUE; else m_bClassSkill = FALSE;
|
|
|
|
m_lpItemBase = new Item::CSkillItem;
|
|
|
|
SetItemPos(cPos);
|
|
SetPos(cIndex);
|
|
m_ipPreIndex = m_lpItemBase->GetPos();
|
|
|
|
((Item::CSkillItem *)m_lpItemBase)->SetSkillInfo(lpSkillProtoType);
|
|
((Item::CSkillItem *)m_lpItemBase)->SetProtoTypeID(wSkillID);
|
|
((Item::CSkillItem *)m_lpItemBase)->SetMaxNumOrDurability(cGrade);
|
|
SetNowDurability(cLevel);
|
|
|
|
m_lCoolDownTime = lpSkillProtoType->m_usCoolDownTime;
|
|
m_lCoolDownTimeCount = lCoolDown;
|
|
|
|
m_lpSprite = new CSprite;
|
|
m_lpSprite->Create(0, 0, GetItemInfo().m_SpriteData.m_nSpriteMinX,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMinY,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMaxX,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMaxY, NULL);
|
|
m_lpTooltip = new CGUITooltipItem;
|
|
((CGUITooltipItem *)m_lpTooltip)->SetItem(this);
|
|
|
|
return TRUE;
|
|
}
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CItemInstance::SetSkillInfo(CItemInstance *lpSkill)
|
|
{
|
|
if(lpSkill)
|
|
{
|
|
m_bSkill = TRUE;
|
|
m_bClassSkill = lpSkill->m_bClassSkill;
|
|
|
|
const Skill::ProtoType *lpSkillProtoType = g_SkillMgr.GetSkillProtoType(lpSkill->GetProtoTypeID());
|
|
if(lpSkillProtoType)
|
|
{
|
|
lpSkillProtoType = &lpSkillProtoType[lpSkill->GetMaxDurability()];
|
|
|
|
if(lpSkillProtoType)
|
|
{
|
|
m_lpItemBase = new Item::CSkillItem;
|
|
|
|
SetPos(lpSkill->m_lpItemBase->GetPos());
|
|
m_ipPreIndex = m_lpItemBase->GetPos();
|
|
|
|
((Item::CSkillItem *)m_lpItemBase)->SetSkillInfo(lpSkillProtoType);
|
|
((Item::CSkillItem *)m_lpItemBase)->SetProtoTypeID(lpSkill->GetProtoTypeID());
|
|
((Item::CSkillItem *)m_lpItemBase)->SetMaxNumOrDurability(lpSkill->GetMaxDurability());
|
|
SetNowDurability(lpSkill->GetNowDurability());
|
|
|
|
m_lCoolDownTime = lpSkill->m_lCoolDownTime;
|
|
m_lCoolDownTimeCount = lpSkill->m_lCoolDownTimeCount;
|
|
m_cCountCooldown = lpSkill->m_cCountCooldown;
|
|
m_wGrade = lpSkill->m_wGrade;
|
|
|
|
m_lpSprite = new CSprite;
|
|
m_lpSprite->Create(0, 0, GetItemInfo().m_SpriteData.m_nSpriteMinX,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMinY,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMaxX,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMaxY, NULL);
|
|
m_lpTooltip = new CGUITooltipItem;
|
|
((CGUITooltipItem *)m_lpTooltip)->SetItem(this);
|
|
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL CItemInstance::GetIsEnableUpgrade()
|
|
{
|
|
if(GetItemInfo().m_DetailData.m_ItemGrade != Item::Grade::RARE)
|
|
{
|
|
unsigned char cItemType = GetItemType();
|
|
if(cItemType == Item::CItemType::ARMOUR || cItemType == Item::CItemType::AXE ||
|
|
cItemType == Item::CItemType::BLUNT || cItemType == Item::CItemType::BOW ||
|
|
cItemType == Item::CItemType::CROSSBOW || cItemType == Item::CItemType::DAGGER ||
|
|
cItemType == Item::CItemType::STAFF || cItemType == Item::CItemType::SWORD ||
|
|
cItemType == Item::CItemType::TWOHANDED_AXE || cItemType == Item::CItemType::TWOHANDED_BLUNT ||
|
|
cItemType == Item::CItemType::TWOHANDED_SWORD)
|
|
{
|
|
return TRUE;
|
|
}
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
void CItemInstance::StartCoolDown(unsigned short wSkillGrade, unsigned char cCountCooldown)
|
|
{
|
|
if(m_bSkill)
|
|
{
|
|
const Skill::ProtoType *lpSkillProtoType = g_SkillMgr.GetSkillProtoType(m_lpItemBase->GetPrototypeID());
|
|
|
|
if(lpSkillProtoType)
|
|
{
|
|
lpSkillProtoType = &lpSkillProtoType[wSkillGrade];
|
|
int nDex = (g_ClientMain.m_csStatus.m_Info.DEX + g_ClientMain.m_csStatus.m_lAddDEX) - 20;
|
|
float fMulti = ((500 - nDex) / 500.0f);
|
|
if(fMulti < 0.5f) fMulti = 0.5f;
|
|
|
|
m_lCoolDownTime = lpSkillProtoType->m_usCoolDownTime * fMulti;
|
|
}
|
|
|
|
m_lCoolDownTimeCount = m_lCoolDownTime;
|
|
m_cCountCooldown = cCountCooldown;
|
|
m_wGrade = wSkillGrade;
|
|
} else
|
|
{
|
|
m_lCoolDownTimeCount = m_lCoolDownTime;
|
|
m_cCountCooldown = cCountCooldown;
|
|
m_wGrade = wSkillGrade;
|
|
}
|
|
}
|
|
|
|
void CItemInstance::ClearCoolDown()
|
|
{
|
|
m_lCoolDownTimeCount = 0;
|
|
m_cCountCooldown = 0;
|
|
m_wGrade = 0;
|
|
}
|
|
|
|
unsigned char CItemInstance::GetSkillType()
|
|
{
|
|
if(m_bSkill)
|
|
{
|
|
const Skill::ProtoType *lpSkillProtoType = g_SkillMgr.GetSkillProtoType(m_lpItemBase->GetPrototypeID());
|
|
|
|
if(lpSkillProtoType) return lpSkillProtoType->m_eSkillType;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
unsigned short CItemInstance::GetSkillIDbyChantID(unsigned char cChant)
|
|
{
|
|
if(m_bSkill)
|
|
{
|
|
const Skill::ProtoType *lpSkillProtoType = g_SkillMgr.GetSkillProtoType(m_lpItemBase->GetPrototypeID());
|
|
if(lpSkillProtoType)
|
|
{
|
|
lpSkillProtoType = &lpSkillProtoType[GetMaxDurability()];
|
|
if(lpSkillProtoType)
|
|
{
|
|
if(lpSkillProtoType->m_cEndCoolDown == cChant)
|
|
{
|
|
return m_lpItemBase->GetPrototypeID();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int CItemInstance::SetItemInfo(CItemInstance *lpItem, Item::ItemPos pItemPos)
|
|
{
|
|
if(lpItem)
|
|
{
|
|
char Buffer[Item::MAX_ITEM_SIZE];
|
|
unsigned int dwItemSize = Item::MAX_ITEM_SIZE;
|
|
lpItem->m_lpItemBase->SerializeOut(Buffer, dwItemSize);
|
|
if(dwItemSize)
|
|
{
|
|
m_lpItemBase = Item::CItemFactory::GetInstance().CreateItem(Buffer, dwItemSize);
|
|
}
|
|
} else
|
|
{
|
|
m_lpItemBase = NULL;
|
|
}
|
|
|
|
if(m_lpItemBase)
|
|
{
|
|
m_lpItemBase->SetPos(pItemPos.m_cIndex);
|
|
m_lpItemBase->SetItemPos(pItemPos.m_cPos);
|
|
m_ipPreIndex = m_lpItemBase->GetPos();
|
|
m_dwItemUID = m_lpItemBase->GetUID();
|
|
|
|
m_lpSprite = new CSprite;
|
|
m_lpSprite->Create(0, 0, GetItemInfo().m_SpriteData.m_nSpriteMinX,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMinY,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMaxX,
|
|
GetItemInfo().m_SpriteData.m_nSpriteMaxY, NULL);
|
|
m_lpTooltip = new CGUITooltipItem;
|
|
((CGUITooltipItem *)m_lpTooltip)->SetItem(this);
|
|
|
|
if(GetItemType() == Item::CItemType::POTION)
|
|
{
|
|
m_lCoolDownTime = 14000;
|
|
m_lCoolDownTimeCount = g_ClientMain.m_csStatus.m_lPotionCoolDownTime;
|
|
}
|
|
|
|
return 1;
|
|
}
|
|
|
|
return 0;
|
|
} |