less than 1 minute read

개인 프로젝트의 무기 관련 내용입니다.

1. 개요

  • 무기는 ULSWeaponDefinition 클래스의 객체로 생성됩니다.
  • 무기의 기본 스탯은 아이템레벨에 따라 결정됩니다.
  • 무기에 랜덤성을 더하기 위해 ULSWeaponAbilityComponent로 속성을 부여했습니다.
  • 무기를 장착하면 기존 무기 데이터 및 장비, 모듈 등의 스탯을 합한 ALSWeaponInstance 객체를 생성하여 ULSEquipmentComponent에 의해 관리됩니다.

2. 스탯 결정

  • 아이템레벨에 따른 무기 스탯 부여를 위해 csv 기반의 데이터 테이블을 이용하였습니다.
  • (사진)
  • 무기 생성시 먼저 ULSWeaponDefinition 객체가 생성됩니다.
  • 이후 랜덤하게 UWeaponAbility를 생성하여 무기에 부착해 줍니다.(구현 예정)
  • 데이터 테이블에서 아이템레벨에 따른 데이터를 가져와 랜덤으로 수치를 조정한 뒤 무기 스탯을 결정합니다.
void ULSWeaponDefinition::SetWeaponDefinitionData(EWeaponType WeaponTypeParam, int32 ItemLevel)
{
	this->WeaponType = WeaponTypeParam;
	WeaponItemLevel = ItemLevel;

	ALSGameState* LSGameState = Cast<ALSGameState>(UGameplayStatics::GetGameState(GetWorld()));
	LSCHECK(LSGameState != nullptr); // check nullptr
	// WeaponBaseData : 아이템레벨에 따른 무기 기본 스탯
	WeaponBaseData = LSGameState->GetLSWeaponData(WeaponItemLevel);
	LSCHECK(WeaponBaseData != nullptr);
	SetWeaponStatsByRandom();
	// 무기에 부착된 속성에 따라 스탯 강화  
	WeaponAbilityComponent->EnhanceWeaponStat(this);
}

void ULSWeaponDefinition::SetWeaponStatsByRandom()
{
	MagazineCapacity = WeaponBaseData->MagazineCapacity + FMath::FRandRange(-10.f, 10.f);
	FireRate = WeaponBaseData->FireRate + FMath::FRandRange(-200.f, 200.f);
	MovementSpeed = WeaponBaseData->MovementSpeed;
	...
}

Leave a comment