194 lines
7.3 KiB
C#
194 lines
7.3 KiB
C#
using BrewMonster;
|
|
using ModelRenderer.Scripts.GameData;
|
|
using System.Collections.Generic;
|
|
using BrewMonster.Network;
|
|
using BrewMonster.Scripts.Managers;
|
|
using BrewMonster.Scripts;
|
|
using CSNetwork.GPDataType;
|
|
namespace PerfectWorld.Scripts.Managers
|
|
{
|
|
/// <summary>
|
|
/// Medicine item class (cac loai thuoc).
|
|
/// This is a part of CEC_IvtrConsume(C++)
|
|
/// </summary>
|
|
public class EC_IvtrMedicine : EC_IvtrItem
|
|
{
|
|
protected MEDICINE_MAJOR_TYPE m_pDBMajorType;
|
|
protected MEDICINE_SUB_TYPE m_pDBSubType;
|
|
protected MEDICINE_ESSENCE m_pDBEssence;
|
|
|
|
protected int m_iLevelReq;
|
|
/// <summary>
|
|
/// Create medicine item (cac loai thuoc)
|
|
/// </summary>
|
|
/// <param name="tid">Template id</param>
|
|
/// <param name="expire_date">Expire date</param>
|
|
public EC_IvtrMedicine(int tid, int expire_date) : base(tid, expire_date)
|
|
{
|
|
m_iCID = (int)InventoryClassId.ICID_MEDICINE;
|
|
elementdataman pDB = ElementDataManProvider.GetElementDataMan();
|
|
DATA_TYPE DataType = DATA_TYPE.DT_INVALID;
|
|
m_pDBEssence = (MEDICINE_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
|
|
m_pDBMajorType = (MEDICINE_MAJOR_TYPE)pDB.get_data_ptr(m_pDBEssence.id_major_type, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
|
|
m_pDBSubType = (MEDICINE_SUB_TYPE)pDB.get_data_ptr(m_pDBEssence.id_sub_type, ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
|
|
m_iPileLimit = m_pDBEssence.pile_num_max;
|
|
m_iPrice = m_pDBEssence.price;
|
|
m_iShopPrice = m_pDBEssence.shop_price;
|
|
m_i64EquipMask = 0;
|
|
m_iLevelReq = m_pDBEssence.require_level;
|
|
m_iProcType = (int)m_pDBEssence.proc_type;
|
|
m_bUseable = true;
|
|
m_bNeedUpdate = false;
|
|
}
|
|
|
|
public EC_IvtrMedicine(EC_IvtrMedicine other) : base(other)
|
|
{
|
|
m_pDBEssence = other.m_pDBEssence;
|
|
m_pDBMajorType = other.m_pDBMajorType;
|
|
m_pDBSubType = other.m_pDBSubType;
|
|
m_iLevelReq = other.m_iLevelReq;
|
|
}
|
|
public override bool SetItemInfo(byte[] pInfoData, int iDataLen)
|
|
{
|
|
base.SetItemInfo(pInfoData, iDataLen);
|
|
return true;
|
|
}
|
|
|
|
// Get item icon file name
|
|
public override string GetIconFile()
|
|
{
|
|
return m_pDBEssence.FileIcon;
|
|
}
|
|
|
|
// Get item name
|
|
public override string GetName()
|
|
{
|
|
return m_pDBEssence.Name;
|
|
}
|
|
public override int GetCoolTime(out int piMax/* NULL */)
|
|
{
|
|
piMax = 1;
|
|
CECHostPlayer pHost = CECGameRun.Instance.GetHostPlayer();
|
|
if (!pHost)
|
|
return 0;
|
|
|
|
int iTime = 0;
|
|
|
|
switch (m_pDBMajorType.id)
|
|
{
|
|
case 1810: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_REJUVENATION_POTION, out piMax); break;
|
|
case 1794: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_HP_POTION, out piMax); break;
|
|
case 1802: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_MP_POTION, out piMax); break;
|
|
case 1815:
|
|
case 2038: iTime = pHost.GetCoolTime((int)CoolTimeIndex.GP_CT_ANTIDOTE_POTION, out piMax); break;
|
|
}
|
|
|
|
return iTime;
|
|
}
|
|
// Get item description text
|
|
protected override string GetNormalDesc(bool bRepair)
|
|
{
|
|
m_strDesc = string.Empty;
|
|
|
|
BMLogger.Log("EC_IvtrMedicine: GetNormalDesc: m_iLevelReq: " + m_iLevelReq);
|
|
// Level requirement
|
|
if (m_iLevelReq > 0)
|
|
{
|
|
BMLogger.Log("EC_IvtrMedicine: m_iLevelReq: " + m_iLevelReq);
|
|
BMLogger.Log("EC_IvtrMedicine: GetMaxLevelSofar: " + CECGameRun.Instance.GetHostPlayer().GetMaxLevelSofar());
|
|
int col = CECGameRun.Instance.GetHostPlayer().GetMaxLevelSofar() >= m_iLevelReq ? (int)DescriptipionMsg.ITEMDESC_COL_WHITE : (int)DescriptipionMsg.ITEMDESC_COL_RED;
|
|
AddDescText(col, true, EC_Game.GetItemDesc().GetWideString((int)DescriptipionMsg.ITEMDESC_LEVELREQ), m_iLevelReq);
|
|
}
|
|
|
|
// Build effect description
|
|
BuildEffectDesc();
|
|
|
|
// Price
|
|
AddPriceDesc((int)DescriptipionMsg.ITEMDESC_COL_WHITE, bRepair);
|
|
|
|
// Extend description
|
|
AddExtDescText();
|
|
|
|
return m_strDesc;
|
|
}
|
|
|
|
// Build medicine effect description
|
|
protected void BuildEffectDesc()
|
|
{
|
|
CECStringTab pDescTab = EC_Game.GetItemDesc();
|
|
int white = (int)DescriptipionMsg.ITEMDESC_COL_WHITE;
|
|
|
|
AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_USEEFFECT));
|
|
|
|
switch (m_pDBMajorType.id)
|
|
{
|
|
case 1794: // Recruit HP
|
|
|
|
if (m_pDBEssence.hp_add_total > 0)
|
|
{
|
|
BMLogger.Log("EC_IvtrMedicine: BuildEffectDesc: m_pDBEssence.hp_add_total: " + m_pDBEssence.hp_add_total);
|
|
BMLogger.Log("EC_IvtrMedicine: BuildEffectDesc: m_pDBEssence.hp_add_time: " + m_pDBEssence.hp_add_time);
|
|
if (m_pDBEssence.hp_add_time > 0)
|
|
AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ADDHPINTIME), m_pDBEssence.hp_add_time, m_pDBEssence.hp_add_total);
|
|
else
|
|
AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_RECRUITHP), m_pDBEssence.hp_add_total);
|
|
}
|
|
|
|
break;
|
|
|
|
case 1802: // Recruit MP
|
|
|
|
if (m_pDBEssence.mp_add_total > 0)
|
|
{
|
|
if (m_pDBEssence.mp_add_time > 0)
|
|
AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ADDMPINTIME), m_pDBEssence.mp_add_time, m_pDBEssence.mp_add_total);
|
|
else
|
|
AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_RECRUITMP), m_pDBEssence.mp_add_total);
|
|
}
|
|
|
|
break;
|
|
|
|
case 1810: // Recruit HP and MP
|
|
|
|
AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_RECRUITHPMP), m_pDBEssence.hp_add_total, m_pDBEssence.mp_add_total);
|
|
break;
|
|
|
|
case 1815:
|
|
|
|
AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_DECHALFPOISON));
|
|
break;
|
|
|
|
case 2038:
|
|
|
|
AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ANTIDOTE));
|
|
break;
|
|
|
|
default:
|
|
|
|
BMLogger.LogError("EC_IvtrMedicine: Unknown major type: " + m_pDBMajorType.id);
|
|
return;
|
|
}
|
|
}
|
|
|
|
// Check item use condition
|
|
protected bool CheckUseCondition()
|
|
{
|
|
CECHostPlayer pHost = CECGameRun.Instance.GetHostPlayer();
|
|
|
|
if (pHost.GetMaxLevelSofar() < m_iLevelReq)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
// Get drop model for shown
|
|
public override string GetDropModel()
|
|
{
|
|
return m_pDBEssence.FileMatter;
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|