////////////////////////////////////////////////////////////////////////////// // 뱀파이어 인벤토리 핸들러 ////////////////////////////////////////////////////////////////////////////// void TransformToWolf::execute(Vampire* pVampire, ObjectID_t InvenObjectID, ObjectID_t InventoryItemObjectID, CoordInven_t X, CoordInven_t Y, CoordInven_t TargetX, CoordInven_t TargetY, VampireSkillSlot* pSkillSlot) throw(Error) { __BEGIN_TRY //cout << "TID[" << Thread::self() << "]" << getSkillHandlerName() << " Begin" << endl; Assert(pVampire != NULL); Assert(pSkillSlot != NULL); try { Player* pPlayer = pVampire->getPlayer(); Zone* pZone = pVampire->getZone(); Inventory* pInventory = pVampire->getInventory(); Assert(pPlayer != NULL); Assert(pZone != NULL); Assert(pInventory!= NULL); SubInventory* pInventoryItem = NULL; int invenID = 0; if (InventoryItemObjectID != 0 ) { //cout << "서브 인벤토리에서 사용 : " << InventoryItemObjectID << endl; CoordInven_t X, Y; pInventoryItem = dynamic_cast<SubInventory*>(pInventory->findItemOID(InventoryItemObjectID, X, Y )); TradeManager* pTradeManager = pZone->getTradeManager(); Assert(pTradeManager != NULL); if (pInventoryItem == NULL || pTradeManager->hasTradeInfo(pVampire->getName()) ) { //cout << "근데 서브 인벤토리가 없다." <<endl; executeSkillFailException(pVampire, getSkillType()); return; } pInventory = pInventoryItem->getInventory(); invenID = pInventoryItem->getItemID(); } Item* pItem = pInventory->getItem(X, Y); Assert(pItem != NULL); // 적당한 아이템이 아니라면 당연히 변신할 수 없다. // PK존에서는 변신할 수 없다. if (pItem->getItemClass() != Item::ITEM_CLASS_VAMPIRE_ETC || pItem->getItemType() != 0 || pVampire->hasRelicItem() || g_pPKZoneInfoManager->isPKZone(pZone->getZoneID() ) || pVampire->isFlag(Effect::EFFECT_CLASS_REFINIUM_TICKET ) || GDRLairManager::Instance().isGDRLairZone(pZone->getZoneID()) ) { executeSkillFailException(pVampire, getSkillType()); //cout << "TID[" << Thread::self() << "]" << getSkillHandlerName() << " End" << endl; return; } GCSkillToInventoryOK1 _GCSkillToInventoryOK1; SkillType_t SkillType = pSkillSlot->getSkillType(); SkillInfo* pSkillInfo = g_pSkillInfoManager->getSkillInfo(SkillType); ZoneCoord_t x = pVampire->getX(); ZoneCoord_t y = pVampire->getY(); // Knowledge of Innate 가 있다면 hit bonus 10 int HitBonus = 0; if (pVampire->hasRankBonus(RankBonus::RANK_BONUS_KNOWLEDGE_OF_INNATE ) ) { RankBonus* pRankBonus = pVampire->getRankBonus(RankBonus::RANK_BONUS_KNOWLEDGE_OF_INNATE); Assert(pRankBonus != NULL); HitBonus = pRankBonus->getPoint(); } int RequiredMP = decreaseConsumeMP(pVampire, pSkillInfo); bool bManaCheck = hasEnoughMana(pVampire, RequiredMP); bool bTimeCheck = verifyRunTime(pSkillSlot); bool bRangeCheck = checkZoneLevelToUseSkill(pVampire); bool bHitRoll = HitRoll::isSuccessMagic(pVampire, pSkillInfo, pSkillSlot, HitBonus); bool bMoveModeCheck = pVampire->isWalking(); bool bEffected = pVampire->isFlag(Effect::EFFECT_CLASS_TRANSFORM_TO_WOLF) || pVampire->isFlag(Effect::EFFECT_CLASS_HAS_FLAG) || pVampire->isFlag(Effect::EFFECT_CLASS_HAS_SWEEPER); if (bManaCheck && bTimeCheck && bRangeCheck && bHitRoll && bMoveModeCheck && !bEffected) { decreaseMana(pVampire, RequiredMP, _GCSkillToInventoryOK1); SkillInput input(pVampire); SkillOutput output; computeOutput(input, output); // 이펙트 클래스를 만들어 붙인다. EffectTransformToWolf* pEffectTTW = new EffectTransformToWolf(pVampire); pEffectTTW->setDeadline(999999999); pVampire->addEffect(pEffectTTW); pVampire->setFlag(Effect::EFFECT_CLASS_TRANSFORM_TO_WOLF); // 이로 인해서 변하는 능력치들을 보내준다. VAMPIRE_RECORD prev; pVampire->getVampireRecord(prev); pVampire->initAllStat(); pVampire->addModifyInfo(prev, _GCSkillToInventoryOK1); _GCSkillToInventoryOK1.setSkillType(SkillType); _GCSkillToInventoryOK1.setCEffectID(0); _GCSkillToInventoryOK1.setDuration(0); pPlayer->sendPacket(&_GCSkillToInventoryOK1); // 뱀파이어 대신 늑대를 더하라고 알려준다. GCAddWolf gcAddWolf; gcAddWolf.setObjectID(pVampire->getObjectID()); gcAddWolf.setName(pVampire->getName()); gcAddWolf.setXYDir(x, y, pVampire->getDir()); gcAddWolf.setItemType(pItem->getItemType()); gcAddWolf.setCurrentHP(pVampire->getHP()); gcAddWolf.setMaxHP(pVampire->getHP(ATTR_MAX)); gcAddWolf.setGuildID(pVampire->getGuildID()); pZone->broadcastPacket(x, y, &gcAddWolf, pVampire); decreaseItemNum(pItem, pInventory, pVampire->getName(), STORAGE_INVENTORY, invenID, X, Y); if (pVampire->getPetInfo() != NULL ) { pVampire->setPetInfo(NULL); sendPetInfo(dynamic_cast<GamePlayer*>(pVampire->getPlayer()), true); } pSkillSlot->setRunTime(output.Delay); } else { executeSkillFailNormal(pVampire, getSkillType(), NULL); } } catch(Throwable & t) { executeSkillFailException(pVampire, getSkillType()); } //cout << "TID[" << Thread::self() << "]" << getSkillHandlerName() << " End" << endl; __END_CATCH }
void CGModifyNicknameHandler::execute (CGModifyNickname* pPacket , Player* pPlayer) throw(ProtocolException, Error) { __BEGIN_TRY __BEGIN_DEBUG_EX #ifdef __GAME_SERVER__ Assert(pPacket != NULL); Assert(pPlayer != NULL); GamePlayer* pGamePlayer = dynamic_cast<GamePlayer*>(pPlayer); Assert(pGamePlayer != NULL); PlayerCreature* pPC = dynamic_cast<PlayerCreature*>(pGamePlayer->getCreature()); Assert(pPC != NULL); Inventory* pInventory = pPC->getInventory(); Assert(pInventory != NULL); GCNicknameVerify gcNV; ObjectID_t itemOID = pPacket->getItemObjectID(); EventGiftBox* pItem = NULL; if (itemOID != 0 ) { pItem = dynamic_cast<EventGiftBox*>(pInventory->getItemWithObjectID(itemOID )); if (pItem == NULL ) { filelog("Nickname.log", "[%s:%s] 아이템이 없거나 EventGiftBox가 아닙니다.", pPlayer->getID().c_str(), pPC->getName().c_str()); gcNV.setCode(NICKNAME_MODIFY_FAIL_NO_ITEM); pGamePlayer->sendPacket(&gcNV); return; } } else { PetInfo* pPetInfo = pPC->getPetInfo(); if (pPetInfo == NULL || pPetInfo->getPetType() != PET_PACKAGE ) { gcNV.setCode(NICKNAME_MODIFY_FAIL_NO_ITEM); pGamePlayer->sendPacket(&gcNV); return; } pPetInfo->setNickname(pPacket->getNickname()); pPetInfo->getPetItem()->savePetInfo(); sendPetInfo(pGamePlayer, true); gcNV.setCode(NICKNAME_MODIFY_OK); pGamePlayer->sendPacket(&gcNV); return; } switch (pItem->getItemType() ) { // 펫 닉네임 바꾸기 case 23 : { PetInfo* pPetInfo = pPC->getPetInfo(); if (pPetInfo == NULL ) { gcNV.setCode(NICKNAME_MODIFY_FAIL_NO_ITEM); pGamePlayer->sendPacket(&gcNV); return; } if (pPetInfo->getPetType() != PET_PACKAGE && pItem == NULL ) { gcNV.setCode(NICKNAME_MODIFY_FAIL_NO_ITEM); pGamePlayer->sendPacket(&gcNV); return; } pPetInfo->setNickname(pPacket->getNickname()); pPetInfo->getPetItem()->savePetInfo(); sendPetInfo(pGamePlayer, true); gcNV.setCode(NICKNAME_MODIFY_OK); pGamePlayer->sendPacket(&gcNV); if (pPetInfo->getPetType() != PET_PACKAGE ) { pInventory->deleteItem(itemOID); pItem->destroy(); SAFE_DELETE(pItem); GCUseOK gcOK; pGamePlayer->sendPacket(&gcOK); } return; } // 커스텀 닉네임 바꾸기 case 22 : case 25 : { NicknameInfo* pNickname = pPC->getNicknameBook()->getNicknameInfo(0); if (pNickname == NULL || pNickname->getNicknameType() != NicknameInfo::NICK_CUSTOM || pPacket->getNickname() == "" ) { gcNV.setCode(NICKNAME_MODIFY_FAIL_NO_ITEM); pGamePlayer->sendPacket(&gcNV); return; } if (pItem == NULL ) { gcNV.setCode(NICKNAME_MODIFY_FAIL_NO_ITEM); pGamePlayer->sendPacket(&gcNV); return; } // pPC->removeFlag(Effect::EFFECT_CLASS_CAN_MODIFY_NICKNAME_0); pNickname->setNickname(pPacket->getNickname()); Statement* pStmt = NULL; BEGIN_DB { pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); pStmt->executeQuery("UPDATE NicknameBook SET Nickname='%s' WHERE OwnerID='%s' AND nID=%u", getDBString(pNickname->getNickname()).c_str(), pPC->getName().c_str(), pNickname->getNicknameID()); SAFE_DELETE(pStmt); } END_DB(pStmt) gcNV.setCode(NICKNAME_MODIFY_OK); pGamePlayer->sendPacket(&gcNV); if (pItem->getItemType() == 22 ) { pInventory->deleteItem(itemOID); pItem->destroy(); SAFE_DELETE(pItem); GCUseOK gcOK; pGamePlayer->sendPacket(&gcOK); } if (pPC->getNickname() == pNickname ) { GCModifyNickname gcMN; gcMN.setObjectID(pPC->getObjectID()); gcMN.setNicknameInfo(pNickname); pPC->getZone()->broadcastPacket(pPC->getX(), pPC->getY(), &gcMN); } break; } // 닉네임 추가하기 case 24 : { if (pItem == NULL ) { gcNV.setCode(NICKNAME_MODIFY_FAIL_NO_ITEM); pGamePlayer->sendPacket(&gcNV); return; } NicknameInfo* pNickname = new NicknameInfo; pNickname->setNicknameID(pPC->getNicknameBook()->popNicknameID()); pNickname->setNicknameType(NicknameInfo::NICK_CUSTOM); pNickname->setNickname(pPacket->getNickname()); pPC->getNicknameBook()->setNicknameInfo(pNickname->getNicknameID(), pNickname); Statement* pStmt = NULL; BEGIN_DB { pStmt = g_pDatabaseManager->getConnection("DARKEDEN")->createStatement(); pStmt->executeQuery("INSERT INTO NicknameBook (nID, OwnerID, NickType, Nickname, Time) " "VALUES (%u, '%s', %u, '%s', now())", pNickname->getNicknameID(), pPC->getName().c_str(), pNickname->getNicknameType(), getDBString(pNickname->getNickname()).c_str()); SAFE_DELETE(pStmt); } END_DB(pStmt) gcNV.setCode(NICKNAME_MODIFY_OK); pGamePlayer->sendPacket(&gcNV); Packet* pNickList = pPC->getNicknameBook()->getNicknameBookListPacket(); pGamePlayer->sendPacket(pNickList); SAFE_DELETE(pNickList); pInventory->deleteItem(itemOID); pItem->destroy(); SAFE_DELETE(pItem); GCUseOK gcOK; pGamePlayer->sendPacket(&gcOK); break; } } #endif // __GAME_SERVER__ __END_DEBUG_EX __END_CATCH }