// /* // * FILE: EC_IvtrWeapon.cpp // * // * DESCRIPTION: // * // * CREATED BY: Duyuxin, 2004/11/19 // * // * HISTORY: // * // * Copyright (c) 2004 Archosaur Studio, All Rights Reserved. // */ // #include "EC_Global.h" // #include "EC_IvtrWeapon.h" // #include "EC_Game.h" // #include "EC_FixedMsg.h" // #include "EC_GameRun.h" // #include "EC_HostPlayer.h" // #include "EC_RTDebug.h" // #include "elementdataman.h" // #include "EC_Configs.h" using BrewMonster; using ModelRenderer.Scripts.GameData; using System.Collections.Generic; using BrewMonster.Network; using BrewMonster.Scripts.Managers; using BrewMonster.Scripts; #region C# regions // #define new A_DEBUG_NEW // /////////////////////////////////////////////////////////////////////////// // // // // Define and Macro // // // /////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////// // // // // Reference to External variables and functions // // // /////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////// // // // // Local Types and Variables and Global variables // // // /////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////// // // // // Local functions // // // /////////////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////////// // // // // Implement CECIvtrWeapon // // // /////////////////////////////////////////////////////////////////////////// #endregion namespace BrewMonster.Scripts { /// /// Weapon item class (cac loai vu khi) /// public class CECIvtrWeapon : EC_IvtrEquip { //Attributes //Weapon essence data protected IVTR_ESSENCE_WEAPON m_Essence; // data in database protected WEAPON_MAJOR_TYPE m_pDBMajorType; protected WEAPON_SUB_TYPE m_pDBSubType; protected WEAPON_ESSENCE m_pDBEssence; public WEAPON_ESSENCE GetDBEssence() { return m_pDBEssence; } /// /// Constructor for weapon item (cac loai vu khi) /// /// Template id public CECIvtrWeapon(int tid, int expire_date) : base(tid, expire_date) { m_iCID = (int)InventoryClassId.ICID_WEAPON; elementdataman pDB = ElementDataManProvider.GetElementDataMan(); DATA_TYPE DataType = DATA_TYPE.DT_INVALID; m_pDBEssence = (WEAPON_ESSENCE)pDB.get_data_ptr((uint)tid, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); m_pDBMajorType = (WEAPON_MAJOR_TYPE)pDB.get_data_ptr(m_pDBEssence.id_major_type, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); m_pDBSubType = (WEAPON_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 = (long)EC_IvtrType.EQUIP_MASK64_WEAPON; m_iProcType = (int)m_pDBEssence.proc_type; FixProps = m_pDBEssence.fixed_props; RepairFee = m_pDBEssence.repairfee; ReputationReq = m_pDBEssence.require_reputation; } public CECIvtrWeapon(CECIvtrWeapon other) : base(other) { m_pDBEssence = other.m_pDBEssence; m_pDBMajorType = other.m_pDBMajorType; m_pDBSubType = other.m_pDBSubType; m_Essence = other.m_Essence; } // CECIvtrWeapon::~CECIvtrWeapon() // { // } public override bool SetItemInfo(byte[] pInfoData, int iDataLen) { base.SetItemInfo(pInfoData, iDataLen); if(pInfoData == null || iDataLen == 0) { return true; } try { CECDataReader dr = new CECDataReader(pInfoData ,iDataLen); // Skip equip requirements and endurance dr.Offset(6 * sizeof(short), CECDataReader.SEEK_CUR); dr.Offset(2 * sizeof(int), CECDataReader.SEEK_CUR); int iEssenceSize = dr.ReadShort(); // Skip maker's information dr.ReadByte(); int iMakerLen = dr.ReadByte(); dr.Offset(iMakerLen, CECDataReader.SEEK_CUR); byte[] iEssenceData = dr.ReadData(iEssenceSize); m_Essence = new IVTR_ESSENCE_WEAPON(iEssenceData); // ���븽������˵�� if(m_pDBEssence.fixed_props != 0 && m_pDBEssence.probability_addon_num0 != 1.0f) { // Get database data elementdataman pDataMan = ElementDataManProvider.GetElementDataMan(); CECStringTab PropTab = EC_Game.GetItemExtProp(); int i, iSize = 0; for(i=0;i<32;i++) { if(m_pDBEssence.addons[i].id_addon != 0) iSize++; } if(iSize > 0 && Props.Count == 0) { Props.Capacity = iSize; for(i=0;i<32;i++) { if(m_pDBEssence.addons[i].id_addon != 0) { Property Prop = new Property(); Prop.Type = (int)m_pDBEssence.addons[i].id_addon; Prop.Embed = false; Prop.Suite = false; Prop.Engraved = false; Prop.Local = false; byte bType = PropTab.GetWideString(Prop.Type) != null ? (byte)0xff : (byte)0xff; DATA_TYPE DataType = DATA_TYPE.DT_INVALID; object pData = pDataMan.get_data_ptr(m_pDBEssence.addons[i].id_addon, ID_SPACE.ID_SPACE_ADDON, ref DataType); if (DataType != DATA_TYPE.DT_EQUIPMENT_ADDON) { return false; } EQUIPMENT_ADDON pAddon = (EQUIPMENT_ADDON)pData; Prop.NumParam = pAddon.num_params; for(int j=0; j < Prop.NumParam; j++) { if(j==0) { Prop.Params[0] = pAddon.param1; } else if(j==1) { Prop.Params[1] = pAddon.param2; } else if(j==2) { Prop.Params[2] = pAddon.param3; } } Props.Add(Prop); } } } } return true; } catch ( System.Exception e) { return false; } } // Get item default information from database public override void DefaultInfo() { LevelReq = m_pDBEssence.require_level; StrengthReq = m_pDBEssence.require_strength; AgilityReq = m_pDBEssence.require_agility; ReputationReq = m_pDBEssence.require_reputation; CurEndurance = m_pDBEssence.durability_min * GameConstants.ENDURANCE_SCALE; MaxEndurance = m_pDBEssence.durability_min * GameConstants.ENDURANCE_SCALE; } // Get item icon file name public override string GetIconFile() { return m_pDBEssence.FileIcon; } // Get item name public override string GetName() { return m_pDBEssence.Name; } // Get preview info public override string GetPreviewInfo() { int[] aPEEVals = new int[MAX_PEEINDEX]; int[] aRefines = new int[MAX_REFINEINDEX]; for(int i=0; i 0) { AddDescText(namecol, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAMESOCKET), GetName(), Holes.Count); } else { AddDescText(namecol, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_NAME), GetName()); } if (RefineLvl > 0) AddDescText(-1, true, "{0} +{1}", pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVEL), RefineLvl); else m_strDesc += "\\r"; AddIDDescText(); AddBindDescText(); // Is destroying? AddDestroyingDesc((int)m_pDBEssence.id_drop_after_damaged, m_pDBEssence.num_drop_after_damaged); AddExpireTimeDesc(); // Sub class name AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_CLASSNAME), m_pDBSubType.Name); // Weapon level AddDescText(-1, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVEL), m_Essence.weapon_level); // Attack speed int col = ((dwPEE & PEE_ATKSPEED) != 0) ? lblue : white; if (Props != null && Props.Count > 0 && Props[0].Local) col = white; AddDescText(col, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ATKSPEED)); AddDescText(col, true, " {0:F2}", 1.0f / (m_Essence.attack_speed * 0.05f)); // Attack distance AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ATKDISTANCE), m_Essence.attack_range - aPEEVals[PEEI_ATKDIST]); // Weak distance if (m_Essence.weapon_type == (int)WEAPON_TYPE.WEAPON_TYPE_RANGE) AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_WEAKDIST), m_Essence.attack_short_range); // Physical damage if (m_Essence.damage_low != 0 || m_Essence.damage_high != 0 || aRefines[REFINE_PHYDAMAGE] != 0) { AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_PHYDAMAGE)); AddDescText(white, true, " {0}-{1}", m_Essence.damage_low - aPEEVals[PEEI_PHYDAMAGE] + aRefines[REFINE_PHYDAMAGE], m_Essence.damage_high - aPEEVals[PEEI_PHYDAMAGE] - aPEEVals[PEEI_MAX_PHYDAMAGE] + aRefines[REFINE_PHYDAMAGE]); } // Magic damage if (m_Essence.magic_damage_low != 0 || m_Essence.magic_damage_high != 0 || aRefines[REFINE_MAGICDAMAGE] != 0) { AddDescText(white, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_MAGICDAMAGE)); AddDescText(white, true, " {0}-{1}", m_Essence.magic_damage_low - aPEEVals[PEEI_MAGICDAMAGE] + aRefines[REFINE_MAGICDAMAGE], m_Essence.magic_damage_high - aPEEVals[PEEI_MAGICDAMAGE] - aPEEVals[PEEI_MAX_MAGICDAMAGE] + aRefines[REFINE_MAGICDAMAGE]); } // Endurance col = white; if (CurEndurance == 0) col = red; else if ((dwPEE & PEE_ENDURANCE) != 0) col = lblue; AddDescText(col, false, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ENDURANCE)); AddDescText(col, true, " {0}/{1}", VisualizeEndurance(CurEndurance), VisualizeEndurance(MaxEndurance)); // Projectile requirement if (m_Essence.weapon_type == (int)WEAPON_TYPE.WEAPON_TYPE_RANGE && m_Essence.require_projectile != 0) { DATA_TYPE DataType = DATA_TYPE.DT_INVALID; object pData = ElementDataManProvider.GetElementDataMan().get_data_ptr((uint)m_Essence.require_projectile, ID_SPACE.ID_SPACE_ESSENCE, ref DataType); PROJECTILE_TYPE pProjectile = (PROJECTILE_TYPE)pData; AddDescText(white, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_PROJECTILE), pProjectile.name); } // Profession requirement AddProfReqDesc((uint)ProfReq); // Level requirment if (LevelReq != 0) { col = pHost.GetMaxLevelSofar() >= LevelReq ? white : red; AddDescText(col, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_LEVELREQ), LevelReq); } // Strength requirment if (StrengthReq != 0) { col = pHost.GetExtendProps().bs.strength < StrengthReq ? red : ((dwPEE & PEE_STRENGTHREQ) != 0 ? lblue : white); AddDescText(col, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_STRENGTHREQ), StrengthReq); } // Agility requirment if (AgilityReq != 0) { col = pHost.GetExtendProps().bs.agility < AgilityReq ? red : ((dwPEE & PEE_AGILITYREQ) != 0 ? lblue : white); AddDescText(col, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_AGILITYREQ), AgilityReq); } // Vitality requirment if (VitalityReq != 0) { col = pHost.GetExtendProps().bs.vitality < VitalityReq ? red : ((dwPEE & PEE_VITALITYREQ) != 0 ? lblue : white); AddDescText(col, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_VITALITYREQ), VitalityReq); } // Energy requirment if (EnergyReq != 0) { col = pHost.GetExtendProps().bs.energy < EnergyReq ? red : ((dwPEE & PEE_ENERGYREQ) != 0 ? lblue : white); AddDescText(col, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_ENERGYREQ), EnergyReq); } // Reputation requirement AddReputationReqDesc(); // Add addon properties if (!string.IsNullOrEmpty(strAddon)) m_strDesc += strAddon; // Build tessera description BuildTesseraDesc(); if(m_pDBEssence.fixed_props == 0 && m_bIsInNPCPack) AddDescText((int)DescriptipionMsg.ITEMDESC_COL2_BRIGHTBLUE, true, pDescTab.GetWideString((int)DescriptipionMsg.ITEMDESC_HASRANDOM_PROP)); // Price AddPriceDesc(white, bRepair); AddSharpenerDesc(); AddEngravedDesc(); AddMakerDesc(); AddSuiteDesc(); AddExtDescText(); return m_strDesc; } // Get weapon attack speed index public int GetAttackSpeedIndex() { float fCurSpeed = m_Essence.attack_speed * 0.05f - m_pDBSubType.attack_speed; if (fCurSpeed < -0.101f) return (int)DescriptipionMsg.ITEMDESC_ATKSPD_VERYFAST; else if (fCurSpeed < -0.001f) return (int)DescriptipionMsg.ITEMDESC_ATKSPD_FAST; else if (fCurSpeed < 0.001f) return (int)DescriptipionMsg.ITEMDESC_ATKSPD_NORMAL; else if (fCurSpeed <= 0.101f) return (int)DescriptipionMsg.ITEMDESC_ATKSPD_SLOW; else return (int)DescriptipionMsg.ITEMDESC_ATKSPD_VERYSLOW; } // // Does this equipment has random property ? public bool HasRandomProp() { for (int i = 0; i < Props.Count; i++) { if (!Props[i].Embed && !Props[i].Engraved && Props[i].Type == 472) return true; } return false; } public int GetRefineMaterialNum() { return m_pDBEssence.material_need; } public override uint GetRefineAddOn() { return (uint)m_pDBEssence.levelup_addon; } public override string GetDropModel() { return m_pDBEssence.FileMatter; } public override bool IsRare() { return base.IsRare() || m_Essence.weapon_level >= 6; } public override int GetItemLevel() { return m_Essence.weapon_level; } // Clone item public override EC_IvtrItem Clone() { return new CECIvtrWeapon(this); } // Get equipment type public virtual int GetEquipmentType() { return 0; // EQUIP_WEAPON = 0 } // The weapon is range weapon ? public bool IsRangeWeapon() { return m_Essence.weapon_type == (int)WEAPON_TYPE.WEAPON_TYPE_RANGE; } // Get essence data public IVTR_ESSENCE_WEAPON GetEssence() { return m_Essence; } // Get database data public WEAPON_MAJOR_TYPE GetDBMajorType() { return m_pDBMajorType; } public WEAPON_SUB_TYPE GetDBSubType() { return m_pDBSubType; } } }