void CFishingManager::Fishing_Ready_Ack(void* pMsg)
{
	MSG_DWORD4* pmsg = (MSG_DWORD4*)pMsg;

	CObject* pObject = OBJECTMGR->GetObject(pmsg->dwObjectID);
	if(!pObject)
		return;

	if(pObject == HERO)
	{
		if(0==pmsg->dwData1 || 0==pmsg->dwData3 || 0==pmsg->dwData4)
			return;

		SetFishingStartTime(gCurTime);
		SetFishingPlace(pmsg->dwData1);

		m_fGaugeStartPos = (float)pmsg->dwData2/100.0f;
		m_dwProcessTime = pmsg->dwData3;
		m_nRepeatCount = pmsg->dwData4;

		LONG maxValue = 0;
		cGuageBar* pGaugeBar = GAMEIN->GetFishingGaugeDlg()->GetFishingGB();
		if(pGaugeBar)
			maxValue = pGaugeBar->GetMaxValue();

		m_fGaugeBarSpeed = ((float)m_nRepeatCount * maxValue) / (float)m_dwProcessTime;
		m_dwUpdateTime = (m_dwProcessTime / m_nRepeatCount) / maxValue;

		m_bActive = TRUE;
	}
	else
	{
		CNpc* pNpc = (CNpc*)OBJECTMGR->GetObject(pmsg->dwData1);
		if(pNpc)
		{
			// 방향전환
			VECTOR3 pos;
			pNpc->GetPosition(&pos);
			MOVEMGR->SetLookatPos(pObject,&pos,0,gCurTime);
		}
	}


	OBJECTSTATEMGR->StartObjectState(pObject, eObjectState_Fishing);
	OBJECTEFFECTDESC desc( FindEffectNum("char_m_fishing_swing_A.beff") );

	pObject->RemoveObjectEffect( FISHING_START_EFFECT );
	pObject->AddObjectEffect( FISHING_START_EFFECT, &desc, 1 );
}
Beispiel #2
0
void cCookManager::Cook_Syn(void* pMsg)
{
	WORD wResult = eCookError_None;
	MSG_COOK_SYN* pmsg = (MSG_COOK_SYN*)pMsg;
	CPlayer* pPlayer = (CPlayer*)g_pUserTable->FindUser(pmsg->dwObjectID);
	
	if(pPlayer)
	{
		// 스피드핵 체크
		if(0 < pPlayer->GetLastCookTime())
		{
			wResult=eCookError_InvaildState;
			goto COOK_NACK;
		}

		// 요리도구확인
		WORD wCookUtilLevel = CheckCookUtil(pPlayer);
		if(!wCookUtilLevel)
		{
			wResult=eCookError_InvaildUtil;			
			goto COOK_NACK;
		}

		// 레시피확인
		stRecipeInfo* pRecipe = GetRecipeInfo(pmsg->dwRecipeIdx);
		if(!pRecipe)
		{
			wResult=eCookError_InvaildRecipe;
			goto COOK_NACK;
		}

		// 요리도구-레시피 레벨확인
		if(wCookUtilLevel<eCOOKLEVEL3 && wCookUtilLevel<COOKMGR->GetCookLevelFromRecipe(pRecipe->dwRecipeIdx))
		{
			wResult=eCookError_LowerUtil;
			goto COOK_NACK;
		}

		// 모닥불확인
		CNpc* pFire = (CNpc*)g_pUserTable->FindUser(pmsg->dwFireNpcIdx);
		if(!pFire || eObjectKind_Npc!=pFire->GetObjectKind())
		{
			wResult=eCookError_InvaildFire;
			goto COOK_NACK;
		}

		// 제작수량확인
		if(pmsg->wMakeNum<1 || 99<pmsg->wMakeNum)
		{
			wResult=eCookError_InvaildMakeNum;
			goto COOK_NACK;
		}

		// 거리제한
		VECTOR3 vHeroPos, vPlacePos;
		pPlayer->GetPosition(&vHeroPos) ;
		pFire->GetPosition(&vPlacePos);
		float fDistance = CalcDistanceXZ(&vHeroPos, &vPlacePos);
		if(MAX_COOKING_DISTANCE < fDistance)
		{
			wResult = eCookError_OverDistance;
			goto COOK_NACK;
		}

		CItemSlot* pInvenSlot = pPlayer->GetSlot(eItemTable_Inventory);
		if(0 == ITEMMGR->GetTotalEmptySlotNum(pInvenSlot, pPlayer))
		{
			wResult = eCookError_InvenFull;
			goto COOK_NACK;
		}

		// 요리재료확인 및 소모
		if(!CheckIngredients(pPlayer, pRecipe, pmsg->wMakeNum))
		{
			wResult = eCookError_NeedIngredient;
			goto COOK_NACK;
		}

		// 숙련도확인 및 증가
		WORD wCookCount = pPlayer->GetCookCount(); 
		WORD wAddPoint = 0;
		if(pPlayer->GetCookLevel() == GetCookLevelFromRecipe(pRecipe->dwRecipeIdx))
		{
			WORD wExpertPointMin = (WORD)pRecipe->dwExpertPointMin;
			WORD wExpertPointMax = (WORD)pRecipe->dwExpertPointMax;
			if(pPlayer->GetCookCount() < wExpertPointMin)
			{
				wResult = eCookError_LowerExpertPoint;
				goto COOK_NACK;
			}
			
			if(wExpertPointMax < wCookCount)
				wAddPoint = 0;
			else if(wExpertPointMax <= wCookCount+pmsg->wMakeNum)
				wAddPoint = wExpertPointMax - wCookCount;
			else
				wAddPoint = pmsg->wMakeNum;

			if(wCookCount+wAddPoint < COOKMGR->GetMaxCookCount(pPlayer->GetCookLevel()))
				pPlayer->SetCookCount(wCookCount + wAddPoint);
			else
				pPlayer->SetCookCount(COOKMGR->GetMaxCookCount(pPlayer->GetCookLevel()));
		}

		Cooking_Update(pPlayer);
		Cooking_Log(pPlayer->GetID(), eCookingLog_CookCount, pRecipe->dwRecipeIdx, wCookCount, wAddPoint, pPlayer->GetCookCount());

		DWORD* pPlayerIdx = new DWORD;
		if(pPlayerIdx)
		{
			*pPlayerIdx = pPlayer->GetID();
			pPlayer->SetLastCookTime(gCurTime);
			m_CookerList.Add(pPlayerIdx, *pPlayerIdx);
		}

		MSG_DWORD2 msgAck;
		msgAck.Category = MP_COOK;
		msgAck.Protocol = MP_COOK_ACK;
		msgAck.dwObjectID = pPlayer->GetID();
		msgAck.dwData1 = pRecipe->dwRecipeIdx;
		msgAck.dwData2 = pmsg->wMakeNum;
		pPlayer->SendMsg(&msgAck, sizeof(msgAck));

		MSG_DWORD4 msg;
		msg.Category = MP_COOK;
		msg.Protocol = MP_COOK_STATE;
		msg.dwObjectID = pPlayer->GetID();
		msg.dwData1 = pPlayer->GetCookLevel();
		msg.dwData2 = pPlayer->GetCookCount();
		msg.dwData3 = pPlayer->GetEatCount();
		msg.dwData4 = pPlayer->GetFireCount();
		pPlayer->SendMsg(&msg, sizeof(msg));

		return;
	}


COOK_NACK:
	MSG_DWORD msg;
	msg.Category = MP_COOK;
	msg.Protocol = MP_COOK_NACK;
	msg.dwObjectID = pPlayer->GetID();
	msg.dwData = wResult;
	PACKEDDATA_OBJ->QuickSend( pPlayer, &msg, sizeof( msg ) );
}
void CFishingManager::SendFishing_Ready(DWORD dwBaitIdx, POSTYPE BaitPos)
{
	const EObjectState IsRestMode = OBJECTSTATEMGR->GetObjectState(HERO) ;

	if(IsRestMode == eObjectState_FishingResult)
	{
		OBJECTSTATEMGR->EndObjectState(HERO, eObjectState_FishingResult);
		OBJECTSTATEMGR->StartObjectState(HERO, eObjectState_None);
	}
	else if(IsRestMode != eObjectState_None)
	{
		CHATMGR->AddMsg( CTC_SYSMSG, CHATMGR->GetChatMsg(1524) );
		goto FISHING_SENDREADY_ERROR;
	}

	if(m_bActive)
	{
		CHATMGR->AddMsg( CTC_SYSMSG, CHATMGR->GetChatMsg(1525) );
		goto FISHING_SENDREADY_ERROR;
	}

	CObject* pObject = OBJECTMGR->GetSelectedObject();
	if(pObject && pObject->GetObjectKind() == eObjectKind_Npc)
	{
		CNpc* pNpc = (CNpc*)pObject;
		if(pNpc->GetNpcJob() != FISHINGPLACE_ROLE)
		{
			CHATMGR->AddMsg( CTC_SYSMSG, CHATMGR->GetChatMsg(1526) );
			goto FISHING_SENDREADY_ERROR;
		}

		if(HERO->GetWeaponEquipType() != eWeaponType_FishingPole)
		{
			CHATMGR->AddMsg( CTC_SYSMSG, CHATMGR->GetChatMsg(1532) );
			goto FISHING_SENDREADY_ERROR;
		}

		if(pNpc->IsDied())
		{
			CHATMGR->AddMsg( CTC_SYSMSG, CHATMGR->GetChatMsg(1524) );
			goto FISHING_SENDREADY_ERROR;
		}

		if(0==dwBaitIdx)
		{
			CHATMGR->AddMsg( CTC_SYSMSG, CHATMGR->GetChatMsg(1527) );
			goto FISHING_SENDREADY_ERROR;
		}

		// 거리제한
		VECTOR3 vHeroPos;
		HERO->GetPosition(&vHeroPos) ;
		float fDistance = CalcDistanceXZ(&vHeroPos, &pObject->GetBaseMoveInfo()->CurPosition) ;
		if(MAX_FISHING_DISTANCE < fDistance) 
		{
			CHATMGR->AddMsg(CTC_SYSMSG, CHATMGR->GetChatMsg(1548)) ;
			goto FISHING_SENDREADY_ERROR;
		}

		// 방향전환
		VECTOR3 pos;
		pNpc->GetPosition(&pos);
		MOVEMGR->SetLookatPos(HERO,&pos,0,gCurTime);

		GAMEIN->GetFishingDlg()->SetLastFishingEndTime(0);

		MSG_FISHING_READY_SYN msg;
		msg.Category = MP_FISHING;
		msg.Protocol = MP_FISHING_READY_SYN;
		msg.dwObjectID = HEROID;
		msg.dwPlaceIdx = pNpc->GetID();
		msg.dwPoleItemIdx = HERO->GetWearedItemIdx(eWearedItem_Weapon);
		msg.wBaitItemPos = BaitPos;
		msg.dwBaitItemIdx = dwBaitIdx;

		NETWORK->Send(&msg, sizeof(msg));
		return;
	}

	CHATMGR->AddMsg( CTC_SYSMSG, CHATMGR->GetChatMsg(1526) );
	goto FISHING_SENDREADY_ERROR;

FISHING_SENDREADY_ERROR:
	GAMEIN->GetFishingDlg()->SetPushStartBtn(FALSE);
	GAMEIN->GetFishingDlg()->SetLastFishingEndTime(0);
}