bool ZWorldItem::ApplyWorldItem( ZCharacter* pCharacter ) { int max,maxBullet,maxMagazine,inc,currentBullet,currentMagazine; if( pCharacter == NULL || ( (m_State != WORLD_ITEM_VALIDATE ) && (m_State != WORLD_ITEM_CANDIDATE)) ) return false; ZItem* pSeletedWeapon = 0; switch( m_Type ) { case WIT_QUEST: break; case WIT_HP: pCharacter->SetHP( min( pCharacter->GetHP() + m_fAmount, pCharacter->GetProperty()->fMaxHP ) ); break; case WIT_AP: pCharacter->SetAP( min( pCharacter->GetAP() + m_fAmount, pCharacter->GetProperty()->fMaxAP ) ); break; case WIT_HPAP: pCharacter->SetHP( min( pCharacter->GetHP() + m_fAmount, pCharacter->GetProperty()->fMaxHP ) ); pCharacter->SetAP( min( pCharacter->GetAP() + m_fAmount, pCharacter->GetProperty()->fMaxAP ) ); break; case WIT_BULLET: pSeletedWeapon = pCharacter->GetItems()->GetSelectedWeapon(); if( pSeletedWeapon && pSeletedWeapon->GetItemType() != MMIT_RANGE ) { if( !pCharacter->GetItems()->GetItem(MMCIP_PRIMARY)->IsEmpty() ) pSeletedWeapon = pCharacter->GetItems()->GetItem(MMCIP_PRIMARY); else if( !pCharacter->GetItems()->GetItem(MMCIP_PRIMARY)->IsEmpty() ) pSeletedWeapon = pCharacter->GetItems()->GetItem(MMCIP_SECONDARY); else pSeletedWeapon = 0; } if( pSeletedWeapon ) { currentBullet = pSeletedWeapon->GetBulletAMagazine(); // 현재 착용한 탄창안의 총알수 currentMagazine = pSeletedWeapon->GetBullet(); // 현재 착용하지 않은 탄창안의 총알수 inc = pSeletedWeapon->GetDesc()->m_nMagazine; // 총알 증가분 max = pSeletedWeapon->GetDesc()->m_nMaxBullet; // 전체 채워질수 있는 총알의 갯수 maxBullet = min((max - currentMagazine),inc); maxMagazine = max - maxBullet; int nBullet = (int)m_fAmount; if( currentBullet < inc ) { pSeletedWeapon->SetBulletAMagazine( maxBullet ); // 현재 탄창의 총알수 채우기 --nBullet; } if( nBullet > 0 ) pSeletedWeapon->SetBullet( min( ( nBullet*inc + currentMagazine ), maxMagazine)); //// MEMORYHACK 방지엔진에 알려준다. if (pCharacter->GetUID() == ZGetMyUID()) { MDataChecker* pChecker = ZApplication::GetGame()->GetDataChecker(); pChecker->RenewCheck((BYTE*)pSeletedWeapon->GetBulletPointer(), sizeof(int)); pChecker->RenewCheck((BYTE*)pSeletedWeapon->GetAMagazinePointer(), sizeof(int)); } } break; default: mlog("정의 되지 않은 아이템 타입입니다\n"); return false; } if( pCharacter == g_pGame->m_pMyCharacter ) { ZGetSoundEngine()->PlaySound("fx_itemget"); } return true; }