📄 vampire_backup.cpp
字号:
//////////////////////////////////////////////////////////////////////////////// Filename : Vampire.cpp// Written By : Elca// Description : //////////////////////////////////////////////////////////////////////////////#include "Vampire.h"#include "Player.h"#include "OptionInfo.h"#include "SkillInfo.h"#include "ItemLoaderManager.h"#include "EffectLoaderManager.h"#include "SkillParentInfo.h"#include "DB.h"#include "ItemInfoManager.h"#include "AbilityBalance.h"#include "Stash.h"#include "TradeManager.h"#include "CreatureUtil.h"#include "FlagSet.h"#include "VampEXPInfo.h"#include "Party.h"#include "ItemUtil.h"#include "PacketUtil.h"#include "SkillUtil.h"#include "Shape.h"#include <stdio.h>#include "item/AR.h"#include "item/SR.h"#include "item/SG.h"#include "item/SMG.h"#include "item/Belt.h"#include "item/Skull.h"#include "skill/EffectBless.h"#include "skill/EffectParalyze.h"#include "skill/EffectDoom.h"#include "skill/EffectTransformToWolf.h"#include "skill/EffectTransformToBat.h"#include "Gpackets/GCModifyInformation.h"#include "Gpackets/GCChangeShape.h"#include "Gpackets/GCSkillInfo.h"#include "Gpackets/GCRealWearingInfo.h"#include "Gpackets/GCStatusCurrentHP.h"#include "Gpackets/GCTakeOff.h"#include "Gpackets/GCOtherModifyInfo.h"////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////void increaseVampExpEx(Vampire* pVampire, Exp_t Point){ Assert(pVampire != NULL); if (Point <= 0) return; Level_t curLevel = pVampire->getLevel(); if (curLevel >= VAMPIRE_MAX_LEVEL) return; Exp_t OldExp = pVampire->getExp(); Exp_t OldGoalExp = pVampire->getGoalExp(); Exp_t NewGoalExp = max(0, (int)(OldGoalExp - Point)); // 穿利 版氰摹俊绰 格钎 版氰摹啊 临绢电 父怒 敲矾胶 窍咯具 茄促. Exp_t DiffGoalExp = max(0, (int)(OldGoalExp - NewGoalExp)); Exp_t NewExp = OldExp + DiffGoalExp; if ((OldExp/VAMPIRE_EXP_SAVE_DIVIDER) != (NewExp/VAMPIRE_EXP_SAVE_DIVIDER)) { /* StringStream attrsave; attrsave << "Exp = " << NewExp << ", GoalExp = " << NewGoalExp; pVampire->tinysave(attrsave.toString()); */ // by sigi. 2002.5.15 char pField[80]; sprintf(pField, "Exp=%ld, GoalExp=%ld", NewExp, NewGoalExp); pVampire->tinysave(pField); } pVampire->setExp(NewExp); pVampire->setGoalExp(NewGoalExp); // 格钎 版氰摹啊 0 捞扼搁 饭骇 诀捞促. if (NewGoalExp == 0 && curLevel < 115) { VAMPIRE_RECORD prev; pVampire->getVampireRecord(prev); curLevel++; pVampire->setLevel(curLevel); // add bonus point Bonus_t bonus = pVampire->getBonus(); if ((pVampire->getSTR(ATTR_BASIC) + pVampire->getDEX(ATTR_BASIC) + pVampire->getINT(ATTR_BASIC) + pVampire->getBonus() - 60) < ((pVampire->getLevel() - 1) * 3)) { // 饭骇俊 惑包摹 臼绊, 公炼扒 3栏肺 函版登菌促. // 2001.12.12 辫己刮 bonus += 3; } pVampire->setBonus(bonus); VampEXPInfo* pBeforeExpInfo = g_pVampEXPInfoManager->getVampEXPInfo(curLevel-1); VampEXPInfo* pNextExpInfo = g_pVampEXPInfoManager->getVampEXPInfo(curLevel); Exp_t NextGoalExp = pNextExpInfo->getGoalExp(); pVampire->setGoalExp(NextGoalExp); /* StringStream sav; sav << "Level = " << (int)curLevel << "," << "Exp = " << (int)pBeforeExpInfo->getAccumExp() << "," << "GoalExp = " << (int)NextGoalExp << "," << "Bonus = " << (int)bonus; pVampire->tinysave(sav.toString()); */ char pField[80]; sprintf(pField, "Level=%d, Exp=%ld, GoalExp=%ld, Bonus=%d", curLevel, pBeforeExpInfo->getAccumExp(), NextGoalExp, bonus); pVampire->tinysave(pField); }}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Vampire::Vampire () throw () : PlayerCreature(0, NULL){ __BEGIN_TRY m_Mutex.setName("Vampire"); // AttackMelee 鞍篮 扁夯 傍拜阑 笼绢持绢霖促. for (int i=0; i<SKILL_DOUBLE_IMPACT; i++) { VampireSkillSlot* pVampireSkillSlot = new VampireSkillSlot; //pVampireSkillSlot = new VampireSkillSlot; // 2002.1.16 by sigi pVampireSkillSlot->setName(m_Name); pVampireSkillSlot->setSkillType(i); pVampireSkillSlot->setInterval(5); pVampireSkillSlot->setRunTime(); addSkill(pVampireSkillSlot); } for (int i = 0; i < VAMPIRE_WEAR_MAX; i++) m_pWearItem[i] = NULL; // 侵 虐甫 檬扁拳 茄促. for (int i = 0; i < 8; i++) { m_HotKey[i] = 0; } m_SilverDamage = 0; m_ClanType = 0; // HP 府哩 矫埃 檬扁拳 getCurrentTime(m_HPRegenTime); // 版氰摹 技捞宏 墨款飘 檬扁拳 m_ExpSaveCount = 0; m_FameSaveCount = 0; m_AlignmentSaveCount = 0; __END_CATCH}Vampire::~Vampire() throw (Error){ __BEGIN_TRY // 汗厘 沥焊甫 积己秦敌促. by sigi. 2002.6.18 DWORD flag; Color_t color[PCVampireInfo::VAMPIRE_COLOR_MAX]; getShapeInfo (flag, color); char pField[128]; sprintf(pField, "Shape=%ld, CoatColor=%d", flag, color[PCVampireInfo::VAMPIRE_COLOR_COAT]); //cout << "SAVE = " << pField << endl; tinysave(pField); // 冻绢柳 酒捞袍狼 郴备己苞 版氰摹, 己氢 殿阑 历厘茄促. saveGears(); saveExps(); saveSkills(); // 涝绊 乐绰 酒捞袍阑 皋葛府俊辑 昏力茄促. destroyGears(); // 努贰胶啊 昏力瞪 版快, 秦寸窍绰 背券 沥焊甫 昏力秦具 窃篮 拱沸, // 背券 惑措俊霸档 捞 荤角阑 舅妨拎具 茄促. TradeManager* pTradeManager = m_pZone->getTradeManager(); TradeInfo* pInfo = pTradeManager->getTradeInfo(getName()); if (pInfo != NULL) { // 背券 沥焊甫 昏力 pTradeManager->cancelTrade(this); } // 臂肺国 颇萍 沥焊甫 昏力茄促. // 老馆利牢 肺弊酒眶狼 版快俊绰 // CGLogoutHandler俊辑 Zone::deleteCreature() 窃荐甫 何福霸 登绊, // 厚沥惑利牢 版快扼绊 秦档, // GamePlayer::disconnect()俊辑 Zone::deleteCreature() 窃荐甫 何福霸 登骨肺, // 肺拿 颇萍 棺 颇萍 檬措, 飘饭捞靛 沥焊甫 捌沥且 鞘夸绰 绝促. deleteAllPartyInfo(this); // 扁贱甸阑 昏力 hash_map<SkillType_t, VampireSkillSlot*>::iterator itr = m_SkillSlot.begin(); for (; itr != m_SkillSlot.end(); itr++) { VampireSkillSlot* pVampireSkillSlot = itr->second; SAFE_DELETE(pVampireSkillSlot); } __END_CATCH}// registerObject// Zone俊 辆加等 ObjectRegistry甫 荤侩秦辑, Vampire 客 家蜡酒捞袍甸狼// ObjectID甫 且寸罐绰促.void Vampire::registerObject () throw (Error){ __BEGIN_TRY Assert(getZone() != NULL); // zone 狼 object registery 俊 立辟茄促. ObjectRegistry & OR = getZone()->getObjectRegistry(); __ENTER_CRITICAL_SECTION(OR) // 快急 轨颇捞绢狼 OID甫 殿废罐绰促. OR.registerObject_NOLOCKED(this); // 牢亥配府狼 酒捞袍甸狼 OID甫 殿废罐绰促. registerInventory(OR); // 厘馒窍绊 乐绰 酒捞袍甸狼 OID甫 殿废罐绰促. for (int i = 0; i < VAMPIRE_WEAR_MAX; i++) { Item* pItem = m_pWearItem[i]; if (pItem != NULL) registerItem(pItem, OR); } // 付快胶俊 甸绊 乐绰 酒捞袍狼 OID甫 殿废 罐绰促. Item* pSlotItem = m_pExtraInventorySlot->getItem(); if (pSlotItem != NULL) registerItem(pSlotItem, OR); m_Garbage.registerObject(OR); __LEAVE_CRITICAL_SECTION(OR) m_VampireInfo.setObjectID(m_ObjectID); __END_CATCH}///////////////////////////////////////////// Vampire客 Slayer荤捞狼 函脚阑 困秦辑// 酒袍 肺爹篮 蝶肺 贸府茄促.//void Vampire::loadItem() throw (InvalidProtocolException, Error){ __BEGIN_TRY // 牢亥配府甫 积己茄促. SAFE_DELETE(m_pInventory); m_pInventory = new Inventory(10, 6); m_pInventory->setOwner(getName()); // 酒捞袍阑 肺靛茄促. g_pItemLoaderManager->load(this); // 肺靛茄 酒捞袍甸阑 殿废矫虐绊 registerObject(); // 涝绊 乐绰 渴俊 蝶扼 瓷仿摹甫 拌魂秦霖促. initAllStat(); __END_CATCH}//----------------------------------------------------------------------//----------------------------------------------------------------------bool Vampire::load () throw (InvalidProtocolException, Error){ __BEGIN_TRY Statement* pStmt = NULL; Result* pResult = NULL; int reward = 0; BEGIN_DB { pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); pResult = pStmt->executeQuery( "SELECT Name, Sex, HairColor, SkinColor, STR, DEX, INTE, HP, CurrentHP, Fame, Exp, GoalExp, ExpOffset, Level, Bonus, InMagics, Gold, GuildID, ZoneID, XCoord, YCoord, Sight, Alignment, F5, F6, F7, F8, F9, F10, F11, F12, StashGold, StashNum, Competence, CompetenceShape, ResurrectZone, SilverDamage, Reward FROM Vampire WHERE Name = '%s' AND Active = 'ACTIVE'", m_Name.c_str() ); if (pResult->getRowCount() == 0) { //throw Error("Critical Error : data intergrity broken. (肺弊牢 辑滚俊辑 霸烙 辑滚肺 逞绢坷绰 悼救俊 某腐磐啊 昏力登菌嚼聪促.)"); SAFE_DELETE(pStmt); return false; } pResult->next(); uint i = 0; setName(pResult->getString(++i)); setSex(pResult->getString(++i)); setHairColor(pResult->getInt(++i)); setSkinColor(pResult->getInt(++i)); m_STR[ATTR_BASIC] = pResult->getInt(++i); m_STR[ATTR_CURRENT] = m_STR[ATTR_BASIC]; m_STR[ATTR_MAX] = m_STR[ATTR_BASIC]; m_DEX[ATTR_BASIC] = pResult->getInt(++i); m_DEX[ATTR_CURRENT] = m_DEX[ATTR_BASIC]; m_DEX[ATTR_MAX] = m_DEX[ATTR_BASIC]; m_INT[ATTR_BASIC] = pResult->getInt(++i); m_INT[ATTR_CURRENT] = m_INT[ATTR_BASIC]; m_INT[ATTR_MAX] = m_INT[ATTR_BASIC]; setHP(pResult->getInt(++i) , ATTR_MAX); setHP(getHP(ATTR_MAX) , ATTR_BASIC); setHP(pResult->getInt(++i) , ATTR_CURRENT); setFame(pResult->getInt(++i)); setExp(pResult->getInt(++i)); setGoalExp(pResult->getInt(++i)); setExpOffset(pResult->getInt(++i)); setLevel(pResult->getInt(++i)); setBonus(pResult->getInt(++i)); setInMagics(pResult->getString(++i)); setGold(pResult->getInt(++i)); setGuildID(pResult->getInt(++i));// setZoneID(pResult->getInt(++i)); ZoneID_t zoneID = pResult->getInt(++i); setX(pResult->getInt(++i)); setY(pResult->getInt(++i)); setSight (pResult->getInt(++i)); setAlignment(pResult->getInt(++i)); for (int j = 0; j < 8; j++) setHotKey(j, pResult->getInt(++i)); setStashGold(pResult->getInt(++i)); setStashNum(pResult->getBYTE(++i)); m_Competence = pResult->getBYTE(++i); m_CompetenceShape = pResult->getBYTE(++i); setResurrectZoneID(pResult->getInt(++i)); m_SilverDamage = pResult->getInt(++i); reward = pResult->getInt(++i); // maxHP甫 促矫 拌魂秦辑 汲沥秦霖促. // 2002.7.15 by sigi // 傍侥 官差搁 AbilityBalance.cpp狼 computeHP档 荐沥秦具茄促. int maxHP = m_STR[ATTR_CURRENT]*2 + m_INT[ATTR_CURRENT] + m_DEX[ATTR_CURRENT]/2 + m_Level; maxHP = min((int)maxHP, VAMPIRE_MAX_HP); setHP( maxHP, ATTR_MAX ); try { setZoneID( zoneID ); } catch ( Error& e ) { // 辨靛 酒瘤飘 巩力肺 夯促. // 辨靛 酒瘤飘啊 茄 霸烙 辑滚俊父 粮犁窍骨肺 促弗 霸烙辑滚肺 立加且 锭 弊 酒瘤飘肺 甸绢啊瘤 给茄促. // 辨靛 酒瘤飘 涝备肺 颗变促. setZoneID( 1003 ); setX( 30 ); setY( 30 ); } SAFE_DELETE(pStmt); } END_DB(pStmt) if (reward != 0) { BEGIN_DB { StringStream SQL; SQL << "UPDATE Vampire SET Reward = 0 WHERE Name = '" << m_Name << "'"; pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); pStmt->executeQuery(SQL.toString()); SAFE_DELETE(pStmt); } END_DB(pStmt) int amount = 0; if (m_Level>=1 && m_Level<=10) amount = m_Level*2000; else if (m_Level>10 && m_Level<=30) amount = m_Level*3000; else if (m_Level>30) amount = m_Level*10000; int offset = 1000; for (int i=0; i<amount; i += offset) { increaseVampExpEx(this, offset); } reward = 0; } //---------------------------------------------------------------------- // Vampire Outlook Information 阑 备己茄促. //---------------------------------------------------------------------- // 轨颇捞绢绰 肺爹且锭 ObjectID甫 技泼 窍档废 茄促. 辟单 立加 且订? -_- m_VampireInfo.setObjectID(m_ObjectID); m_VampireInfo.setName(m_Name); m_VampireInfo.setSex(m_Sex); m_VampireInfo.setHairColor(m_HairColor); m_VampireInfo.setSkinColor(m_SkinColor); m_VampireInfo.setCompetence(m_CompetenceShape); //---------------------------------------------------------------------- // 胶懦阑 肺爹茄促. //---------------------------------------------------------------------- BEGIN_DB { pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); pResult = pStmt->executeQuery("SELECT SkillType, Delay, CastingTime, NextTime FROM VampireSkillSave WHERE OwnerID = '%s'", m_Name.c_str()); while(pResult->next()) { int i = 0; SkillType_t SkillType = pResult->getInt(++i); if (hasSkill(SkillType) == NULL) { VampireSkillSlot* pVampireSkillSlot = new VampireSkillSlot(); pVampireSkillSlot->setName(m_Name); pVampireSkillSlot->setSkillType(SkillType); pVampireSkillSlot->setInterval (pResult->getInt(++i)); pVampireSkillSlot->setCastingTime (pResult->getInt(++i)); //pVampireSkillSlot->setRunTime (pResult->getInt(++i)); pVampireSkillSlot->setRunTime(); addSkill(pVampireSkillSlot); } } SAFE_DELETE(pStmt); } END_DB(pStmt) //---------------------------------------------------------------------- // 捞棋飘甫 肺爹茄促. //---------------------------------------------------------------------- g_pEffectLoaderManager->load(this); //---------------------------------------------------------------------- // 敲贰弊 悸阑 肺靛茄促. //---------------------------------------------------------------------- m_pFlagSet->load(getName()); //---------------------------------------------------------------------- // Vampire Outlook Information 阑 檬扁拳茄促. //---------------------------------------------------------------------- /* ItemType_t coatType = 0; Item* pItem = m_pWearItem[WEAR_BODY]; if (pItem!=NULL) { coatType = pItem->getItemType(); } */ m_VampireInfo.setCoatType( 0 ); m_VampireInfo.setCoatColor(JACKET_BASIC); m_VampireInfo.setCoatColor(377); //m_VampireInfo.setCoatColor(2 , SUB_COLOR); // 肋给等 版氰摹甫 犁炼沥 秦霖促. VampEXPInfo* pVampEXPInfo = g_pVampEXPInfoManager->getVampEXPInfo(m_Level);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -