Unreal - 퀘스트 시스템2

2025. 12. 22. 07:08·Unreal 프로젝트 다이어리/두번째 프로젝트

이번 글은 저번 퀘스트 시스템 글에서 이어집니다

 

2025.12.19 - [Unreal 프로젝트 다이어리/두번째 프로젝트] - Unreal - 퀘스트 시스템

 

Unreal - 퀘스트 시스템

구현내용플레이어가 NPC 에게 퀘스트를 의뢰하고, 해당 퀘스트를 완료하면보상을 획득하는 NPC 의뢰 기반으로 퀘스트 수락 - 진행 - 완료 - 보상 까지이어지는 퀘스트 시스템을 구현하였습니다.

lucodev.tistory.com

미리보기

구현내용

퀘스트 시스템의 디테일을 추가 구현하였습니다

구현된 내용은 이와 같습니다

  • 플레이어가 진행할 수 있는 퀘스트가 있으면 Npc 머리위에 ? 를 표기합니다
  • 플레이어가 완료 할 수 있는 퀘스트가 있으면 Npc 머리위에 ! 를 표기합니다
  • 배달 퀘스트의 로직을 구현

구현

추가된 머리위의 퀘스트 마커 업데이트 내용

모든 Npc의 부모 객체인 BasNpc에 퀘스트 마커 업데이트 함수 제작

void ABasicNpc::UpdateQuestMarker(bool bShowAccept, bool bShowComplete)
{
	if (!questMarkerNa) 
		return;

	questMarkerNa->Deactivate();
	questMarkerNa->SetAsset(nullptr);

	if (bShowAccept && questAcceptNiagara)
	{
		questMarkerNa->SetAsset(questAcceptNiagara);
		questMarkerNa->Activate(true);
	}
	else if (bShowComplete && questCompleteNiagara)
	{
		questMarkerNa->SetAsset(questCompleteNiagara);
		questMarkerNa->Activate(true);
	}
}

 

QuestComponent  수정

UpdateNpcQuestMarkers함수 추가

void UQuestComponent::UpdateNpcQuestMarkers()
{
	for (TActorIterator<ABasicNpc> it(GetWorld()); it; ++it)
	{
		ABasicNpc* npc = *it;
		if (!npc)
			continue;

		int32 acceptableQuestCount = 0;
		int32 completableQuestCount = 0;

		if (npc->IsA(AShopQuestNPC::StaticClass()))
		{
			for (auto& questPair : questManager->GetAllQuests())
			{
				const FQuestData& questData = questPair.Value;
				if (!activeQuest.Contains(questData.QuestID))
					acceptableQuestCount++;
			}

			for (auto& questPair : activeQuest)
			{
				const FQuestProgress& progress = questPair.Value;
				const FQuestData* questData = questManager->GetQuestData(progress.progressQuestID);
				if (questData && progress.bCompleted)
					completableQuestCount++;
			}
		}
		else if (npc->IsA(ANpcCiel::StaticClass()))
		{
			// 기본값 숨김
			acceptableQuestCount = 0;
			completableQuestCount = 0;

			const FQuestProgress* progress = activeQuest.Find(3);
			if (progress && !progress->bCompleted)
				completableQuestCount = 1; 

			npc->UpdateQuestMarker(false, completableQuestCount > 0);
			continue; 
		}

		if (completableQuestCount > 0)
			npc->UpdateQuestMarker(false, true); // !
		else if (acceptableQuestCount > 0)
			npc->UpdateQuestMarker(true, false); // ?
		else
			npc->UpdateQuestMarker(false, false); // 숨김
	}
}

 

 

배달 로직 구현

void UQuestComponent::OnDeliverItem(int32 itemID, int32 npcID)
{
	EachActiveQuest([this, itemID, npcID](FQuestProgress& progress, const FQuestData* questData)
		{
			if (questData->questType != EQuestType::Deliver)
				return false;

			if (questData->targetID != itemID)
				return false;

			if (questData->targetNpcID != 0 && questData->targetNpcID != npcID)
				return false;


			progress.progressCurrentCount++;

			if (progress.progressCurrentCount >= questData->targetCount)
			{
				progress.bCompleted = true;

				if (progress.progressQuestID == 3)
					guideManager->EndSingleTarget("NPC_1");
			}
			return true;
		});
	UpdateNpcQuestMarkers();
}

 

결과

받을수 있는 퀘스트가 존재하면 머리위에 ? 로 표시됩니다

 

퀘스트를 완료시 ? 에서 ! 로 변경됩니다

 

배달 시스템은 도저히 Gif로 한번에 다 담을수 없어서 영상으로 설명드리겠습니다

영상

 

이걸 하나를 구현하기위에 수많은 클래스 작업이 있었네요..

월드마커가 꽤나 이쁘게 구현된거같습니다 :)

저작자표시 비영리 변경금지 (새창열림)

'Unreal 프로젝트 다이어리 > 두번째 프로젝트' 카테고리의 다른 글

Unreal - 버프창  (0) 2025.12.27
Unreal - 퀵슬롯  (0) 2025.12.27
Unreal - 가이드 마커  (0) 2025.12.22
Unreal - 대화 Npc  (0) 2025.12.22
Unreal - 퀘스트 시스템  (0) 2025.12.19
'Unreal 프로젝트 다이어리/두번째 프로젝트' 카테고리의 다른 글
  • Unreal - 버프창
  • Unreal - 퀵슬롯
  • Unreal - 가이드 마커
  • Unreal - 대화 Npc
lucodev
lucodev
언리얼 포폴개발 일기
  • lucodev
    루코 개발테이블
    lucodev
  • 전체
    오늘
    어제
    • 분류 전체보기 (236)
      • Unreal 프로젝트 다이어리 (132)
        • 첫번째 프로젝트 (73)
        • 두번째 프로젝트 (59)
      • Unreal 팁 (8)
      • Unreal 디버깅 (8)
      • C++ 프로그래머스 (52)
        • Stack,Queue (7)
        • Hash (4)
        • Heap (2)
        • Sort (5)
        • Exhaustive search (5)
        • Greedy (2)
        • BFS , DFS (7)
        • Graph (2)
        • Dynamic Programming (1)
        • C++ Math (2)
        • 기타 문제 (14)
      • C++ 백준 (5)
      • C++ 팁 (1)
      • 개인 코테 & 스타디 <비공개> (29)
        • 코드 개인보관함 (9)
        • 코딩테스트+@ (11)
        • 알고리즘 스타디 (6)
        • 알고리즘 스타디 과제 (3)
        • 비공개 (0)
  • 인기 글

  • 최근 글

  • 최근 댓글

  • 링크

  • 공지사항

  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 태그

    unreal 상호작용
    언리얼 세키로
    언리얼 behavior tree
    언리얼 상호작용
    unreal 세키로
    언리얼 컷씬
    언리얼 ui
    언리얼 인벤토리
    unreal 인벤토리
    unreal 파쿠르
    unreal inventory
    언리얼 parkour
    언리얼 비헤이비어트리
    언리얼
    unreal npc
    언리얼 behaviortree
    언리얼 파쿠르
    unreal
    언리얼 인터렉션
    언리얼 시퀀스
  • hELLO· Designed By정상우.v4.10.3
lucodev
Unreal - 퀘스트 시스템2
상단으로

티스토리툴바