// ЖЇБ¤ їлИҐј®А» АеєсГўїЎј Б¦°ЕЗТ ¶§їЎ јє°ш ї©єОё¦ °бБ¤ЗП°н, ЅЗЖРЅГ єО»к№°А» БЦґВ ЗФјц. bool DSManager::PullOut(LPCHARACTER ch, TItemPos DestCell, LPITEM& pItem, LPITEM pExtractor) { if (NULL == ch || NULL == pItem) { sys_err ("NULL POINTER. ch(%p) or pItem(%p)", ch, pItem); return false; } // ёсЗҐ А§ДЎ°Ў validЗСБц °Л»з ИД, validЗПБц ѕКґЩёй АУАЗАЗ єу °ш°ЈА» ГЈґВґЩ. if (!IsValidCellForThisItem(pItem, DestCell)) { int iEmptyCell = ch->GetEmptyDragonSoulInventory(pItem); if (iEmptyCell < 0) { ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("јТБцЗ°їЎ єу °ш°ЈАМ ѕшЅАґПґЩ.")); return false; } else { DestCell.window_type = DRAGON_SOUL_INVENTORY; DestCell.cell = iEmptyCell; } } if (!pItem->IsEquipped() || !pItem->RemoveFromCharacter()) return false; bool bSuccess; DWORD dwByProduct = 0; int iBonus = 0; float fProb; float fDice; // їлИҐј® ГЯГв јє°ш ї©єО °бБ¤. { DWORD dwVnum = pItem->GetVnum(); BYTE ds_type, grade_idx, step_idx, strength_idx; GetDragonSoulInfo(pItem->GetVnum(), ds_type, grade_idx, step_idx, strength_idx); // ГЯГв Б¤єё°Ў ѕшґЩёй АПґЬ №«Б¶°З јє°шЗПґВ °НАМ¶у »э°ўЗПАЪ. if (!m_pTable->GetDragonSoulExtValues(ds_type, grade_idx, fProb, dwByProduct)) { pItem->AddToCharacter(ch, DestCell); return true; } if (NULL != pExtractor) { iBonus = pExtractor->GetValue(ITEM_VALUE_DRAGON_SOUL_POLL_OUT_BONUS_IDX); pExtractor->SetCount(pExtractor->GetCount() - 1); } fDice = fnumber(0.f, 100.f); bSuccess = fDice <= (fProb * (100 + iBonus) / 100.f); } // ДіёЇЕНАЗ їлИҐј® ГЯГв №Ч ГЯ°Ў И¤Ає Б¦°Е. єО»к№° Б¦°ш. { char buf[128]; if (bSuccess) { if (pExtractor) { sprintf(buf, "dice(%d) prob(%d + %d) EXTR(VN:%d)", (int)fDice, (int)fProb, iBonus, pExtractor->GetVnum()); } else { sprintf(buf, "dice(%d) prob(%d)", fDice, fProb); } LogManager::instance().ItemLog(ch, pItem, "DS_PULL_OUT_SUCCESS", buf); ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("їлИҐј® ГЯГвїЎ јє°шЗПїґЅАґПґЩ.")); pItem->AddToCharacter(ch, DestCell); return true; } else { if (pExtractor) { sprintf(buf, "dice(%d) prob(%d + %d) EXTR(VN:%d) ByProd(VN:%d)", (int)fDice, (int)fProb, iBonus, pExtractor->GetVnum(), dwByProduct); } else { sprintf(buf, "dice(%d) prob(%d) ByProd(VNUM:%d)", (int)fDice, (int)fProb, dwByProduct); } LogManager::instance().ItemLog(ch, pItem, "DS_PULL_OUT_FAILED", buf); M2_DESTROY_ITEM(pItem); pItem = NULL; if (dwByProduct) { LPITEM pByProduct = ch->AutoGiveItem(dwByProduct, true); if (pByProduct) ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("їлИҐј® ГЯГвїЎ ЅЗЖРЗПї© %sё¦ ѕтѕъЅАґПґЩ."), pByProduct->GetName()); else ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("їлИҐј® ГЯГвїЎ ЅЗЖРЗПїґЅАґПґЩ.")); } else ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("їлИҐј® ГЯГвїЎ ЅЗЖРЗПїґЅАґПґЩ.")); } } return bSuccess; }
// 특정 용혼석을 장비창에서 제거할 때에 성공 여부를 결정하고, 실패시 부산물을 주는 함수. bool DSManager::PullOut(LPCHARACTER ch, TItemPos DestCell, LPITEM& pItem, LPITEM pExtractor) { if (NULL == ch || NULL == pItem) { sys_err ("NULL POINTER. ch(%p) or pItem(%p)", ch, pItem); return false; } // 목표 위치가 valid한지 검사 후, valid하지 않다면 임의의 빈 공간을 찾는다. if (!IsValidCellForThisItem(pItem, DestCell)) { int iEmptyCell = ch->GetEmptyDragonSoulInventory(pItem); if (iEmptyCell < 0) { ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("소지품에 빈 공간이 없습니다.")); return false; } else { DestCell.window_type = DRAGON_SOUL_INVENTORY; DestCell.cell = iEmptyCell; } } if (!pItem->IsEquipped() || !pItem->RemoveFromCharacter()) return false; bool bSuccess; DWORD dwByProduct = 0; int iBonus = 0; float fProb; float fDice; // 용혼석 추출 성공 여부 결정. { DWORD dwVnum = pItem->GetVnum(); BYTE ds_type, grade_idx, step_idx, strength_idx; GetDragonSoulInfo(pItem->GetVnum(), ds_type, grade_idx, step_idx, strength_idx); // 추출 정보가 없다면 일단 무조건 성공하는 것이라 생각하자. if (!m_pTable->GetDragonSoulExtValues(ds_type, grade_idx, fProb, dwByProduct)) { pItem->AddToCharacter(ch, DestCell); return true; } if (NULL != pExtractor) { iBonus = pExtractor->GetValue(ITEM_VALUE_DRAGON_SOUL_POLL_OUT_BONUS_IDX); pExtractor->SetCount(pExtractor->GetCount() - 1); } fDice = fnumber(0.f, 100.f); bSuccess = fDice <= (fProb * (100 + iBonus) / 100.f); } // 캐릭터의 용혼석 추출 및 추가 혹은 제거. 부산물 제공. { char buf[128]; if (bSuccess) { if (pExtractor) { sprintf(buf, "dice(%d) prob(%d + %d) EXTR(VN:%d)", (int)fDice, (int)fProb, iBonus, pExtractor->GetVnum()); } else { sprintf(buf, "dice(%d) prob(%d)", fDice, fProb); } LogManager::instance().ItemLog(ch, pItem, "DS_PULL_OUT_SUCCESS", buf); ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("용혼석 추출에 성공하였습니다.")); pItem->AddToCharacter(ch, DestCell); return true; } else { if (pExtractor) { sprintf(buf, "dice(%d) prob(%d + %d) EXTR(VN:%d) ByProd(VN:%d)", (int)fDice, (int)fProb, iBonus, pExtractor->GetVnum(), dwByProduct); } else { sprintf(buf, "dice(%d) prob(%d) ByProd(VNUM:%d)", (int)fDice, (int)fProb, dwByProduct); } LogManager::instance().ItemLog(ch, pItem, "DS_PULL_OUT_FAILED", buf); M2_DESTROY_ITEM(pItem); pItem = NULL; if (dwByProduct) { LPITEM pByProduct = ch->AutoGiveItem(dwByProduct, true); if (pByProduct) ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("용혼석 추출에 실패하여 %s를 얻었습니다."), pByProduct->GetName()); else ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("용혼석 추출에 실패하였습니다.")); } else ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("용혼석 추출에 실패하였습니다.")); } } return bSuccess; }