void ASCharacter::RemoveWeapon(class ASWeapon* Weapon, bool bDestroy)
{
	if (Weapon && Role == ROLE_Authority)
	{
		bool bIsCurrent = CurrentWeapon == Weapon;

		if (Inventory.Contains(Weapon))
		{
			Weapon->OnLeaveInventory();
		}
		Inventory.RemoveSingle(Weapon);

		/* Replace weapon if we removed our current weapon */
		if (bIsCurrent && Inventory.Num() > 0)
		{
			SetCurrentWeapon(Inventory[0]);
		}			

		/* Clear reference to weapon if we have no items left in inventory */
		if (Inventory.Num() == 0)
		{
			SetCurrentWeapon(nullptr);
		}

		if (bDestroy)
		{
			Weapon->Destroy();
		}
	}
}
void ASCharacter::PawnClientRestart()
{
	Super::PawnClientRestart();

	/* Equip the weapon on the client side. */
	SetCurrentWeapon(CurrentWeapon);
}
예제 #3
0
void AMech_RPGCharacter::Reset()
{
	if (GetCurrentWeapon() != nullptr) {
		GetCurrentWeapon()->Destroy();
		SetCurrentWeapon(nullptr);
	}

	abilities.Empty();
	armour.Empty();

	if (GetInventory() != nullptr) {
		GetInventory()->GetItems().Empty();
	}

	inventory = NewObject<UInventory>(UInventory::StaticClass());

	SetHealth(GetMaxHealth());

	channeling = false;
	inCombat = false;

	canAttack = 0;
	canMove = 0;
	canBeDamaged = 0;
}
예제 #4
0
void ALonelyMenCharacter::EquipWeapon(class ALMWeapon* weapon)
{
	if (weapon)
	{
		SetCurrentWeapon(weapon);
	}
}
예제 #5
0
void AAmethystCharacter::PawnClientRestart()
{
	Super::PawnClientRestart();

	// switch mesh to 1st person view
	UpdatePawnMeshes();

	// reattach weapon if needed
	SetCurrentWeapon(CurrentWeapon);

}
예제 #6
0
AMech_RPGCharacter::~AMech_RPGCharacter() {
	characters.Remove(this);
	abilities.Empty();
	armour.Empty();

	if (GetCurrentWeapon() != nullptr) {
		GetCurrentWeapon()->Destroy();
		SetCurrentWeapon(nullptr);
	}

	if (mIsChildOf(GetController(), AMech_RPGPlayerController::StaticClass())) {
		UMiscLibrary::SetPlayerController(nullptr);
	}
}
예제 #7
0
void AAmethystCharacter::EquipWeapon(AAmethystWeapon* Weapon)
{
	if (Weapon)
	{
		if (Role == ROLE_Authority)
		{
			SetCurrentWeapon(Weapon);
		}
		else
		{
			ServerEquipWeapon(Weapon);
		}
	}
}
예제 #8
0
void ANimModCharacter::EquipWeapon(ANimModWeapon* Weapon)
{
	if (Weapon)
	{
		if (Role == ROLE_Authority)
		{
			SetCurrentWeapon(Weapon);
		}
		else
		{
			ServerEquipWeapon(Weapon);
		}
	}
}
예제 #9
0
void ANimModCharacter::PawnClientRestart()
{
	Super::PawnClientRestart();

	// switch mesh to 1st person view
	UpdatePawnMeshes();

	// reattach weapon if needed
	SetCurrentWeapon(CurrentWeapon);

	// set team colors for 1st person view

	//The material's index that we want is 1, not 0.
	UMaterialInstanceDynamic* Mesh1PMID = Mesh1P->CreateAndSetMaterialInstanceDynamic(1);
	UpdateTeamColors(Mesh1PMID);
}
예제 #10
0
void ASCharacter::EquipWeapon(ASWeapon* Weapon)
{
	if (Weapon)
	{
		/* Ignore if trying to equip already equipped weapon */
		if (Weapon == CurrentWeapon)
			return;

		if (Role == ROLE_Authority)
		{
			SetCurrentWeapon(Weapon, CurrentWeapon);
		}
		else
		{
			ServerEquipWeapon(Weapon);
		}
	}
}
예제 #11
0
bool Player::init()
{
	if (false == CCNode::init())
		return false;

	CCSprite* pSprite = CCSprite::create("hero.png");

	if (NULL == pSprite)
	{
		return false;
	}

	SetCurrentWeapon(Weapon::create());

	addChild(pSprite);
	scheduleUpdate();
	return true;
}
예제 #12
0
void AAgent::EquipWeapon(ABaseWeapon* NewWeapon)
{
	// Get the currently equipped weapon
	if (GetCurrentWeapon() != NULL)
		// Destroy that weapon
		GetCurrentWeapon()->Destroy();

	// Spawn and equip the rifle
	FActorSpawnParameters SpawnParams;
	SpawnParams.Owner = this;
	SpawnParams.Instigator = Instigator;
	UWorld* World = GetWorld();
	if (World)
	{
		// Here we would spawn in the NewWeapon object and attach it
		// to the rootcomponent of the character. However I do have a
		// shotgun or a pistol asset (mesh, skeletal, material etc.) so
		// to visualize that they are equipped I shall merely display the 
		// shotgun or pistol animations respectively.
		if (NewWeapon == SpawnedPistol && ((NewWeapon && SpawnedPistol) != NULL))
		{
			bRifleEquipped = false;
			bShotgunEquipped = false;
			bPistolEquipped = true;

			NewWeapon = World->SpawnActor<APistol>(SpawnParams);
			if (NewWeapon != NULL)
			{
				NewWeapon->AttachRootComponentTo(ManMesh, TEXT("GunSocket"), EAttachLocation::SnapToTargetIncludingScale, true);
				SetCurrentWeapon(NewWeapon);
			}
		}
		else if (NewWeapon == SpawnedShotgun && ((NewWeapon && SpawnedShotgun) != NULL))
		{
			bRifleEquipped = false;
			bShotgunEquipped = true;
			bPistolEquipped = false;

			NewWeapon = World->SpawnActor<AShotgun>(SpawnParams);
			if (NewWeapon != NULL)
			{
				NewWeapon->AttachRootComponentTo(ManMesh, TEXT("GunSocket"), EAttachLocation::SnapToTargetIncludingScale, true);
				SetCurrentWeapon(NewWeapon);
			}
		}
		// However because the Rifle does have a mesh the spawn and attach code will need
		// to be added specifically for the instance where the rifle is equipped.
		else
		{
			bRifleEquipped = true;
			bShotgunEquipped = false;
			bPistolEquipped = false;

			NewWeapon = World->SpawnActor<ARifle>(SpawnParams);
			if (NewWeapon != NULL)
			{
				NewWeapon->AttachRootComponentTo(ManMesh, TEXT("GunSocket"), EAttachLocation::SnapToTargetIncludingScale, true);
				SetCurrentWeapon(NewWeapon);
			}
		}
	}
}
예제 #13
0
void ASCharacter::OnRep_CurrentWeapon(ASWeapon* LastWeapon)
{
	SetCurrentWeapon(CurrentWeapon, LastWeapon);
}
예제 #14
0
void AMech_RPGCharacter::CreatePresetRole(TEnumAsByte<GroupEnums::Role> inRole, int32 grade, int32 quaility) {
	float blastResistance = 5;
	float phsyicalResistance = 5;
	float energyResistance = 5;
	float statModifier = 0;
	static float lowHealth = 2000;
	static float mediumHealth = lowHealth * 1.25;
	static float highHealth = mediumHealth * 1.25;

	Reset();

	StartingRole(inRole);

	isPlayer = mIsChildOf(GetController(), AMech_RPGPlayerController::StaticClass());
	//isAlly = mIsChildOf(GetController(), AAllyAIController::StaticClass());

	//if (isAlly || isPlayer) {
	//	statModifier = GetModifierForDifficulty(UMiscLibrary::GetDifficulty());
	//}

	switch (inRole) {
	case GroupEnums::DPS:
		SetCurrentWeapon(mCreatePresetWeapon(WeaponEnums::SMG, grade, quaility));
		AddAbility(UAbility::CreateChannelledPresetAbility(this, AbilityEnums::Grenade, 1.75F, true, true));
		AddAbility(UTimedHealthChange::CreateTimedHealthChange(this, 10.0F, 2.0F));
		SetDefenceModifier(0.0F + statModifier);
		SetHealthChangeModifier(1.0F + statModifier);
		SetSpeedModifier(1.0F + statModifier);
		blastResistance = AArmour::GetDeafultValue(ArmourGrades::Light);
		phsyicalResistance = AArmour::GetDeafultValue(ArmourGrades::MediumLight);
		energyResistance = AArmour::GetDeafultValue(ArmourGrades::Light);
		SetMaxHealth(lowHealth * (1 + statModifier));
		break;

	case GroupEnums::Healer:
		SetCurrentWeapon(mCreatePresetWeapon(WeaponEnums::Bio_Repair, grade, quaility));
		AddAbility(mCreatePresetAbility(AbilityEnums::Heal));
		AddAbility(mCreatePresetAbility(AbilityEnums::AoEHeal));
		AddAbility(UTimedHealthChange::CreateTimedHealthChange(this, 10.0F, 2.0F));
		SetDefenceModifier(0.0F + statModifier);
		SetHealthChangeModifier(1.0F + statModifier);
		SetSpeedModifier(1.0F + statModifier);
		blastResistance = AArmour::GetDeafultValue(ArmourGrades::Light);
		phsyicalResistance = AArmour::GetDeafultValue(ArmourGrades::MediumLight);
		energyResistance = AArmour::GetDeafultValue(ArmourGrades::Light);
		SetMaxHealth(lowHealth * (1 + statModifier));
		break;

	case GroupEnums::Tank:
		SetCurrentWeapon(mCreatePresetWeapon(WeaponEnums::Shotgun, grade, quaility));
		AddAbility(mCreatePresetAbility(AbilityEnums::Taunt));
		AddAbility(mCreatePresetAbility(AbilityEnums::Stun));
		SetDefenceModifier(0.0F + statModifier);
		SetHealthChangeModifier(1.0F + statModifier);
		SetSpeedModifier(1.0F + statModifier);
		blastResistance = AArmour::GetDeafultValue(ArmourGrades::MediumHeavy);
		phsyicalResistance = AArmour::GetDeafultValue(ArmourGrades::Heavy);
		energyResistance = AArmour::GetDeafultValue(ArmourGrades::Medium);
		SetMaxHealth(highHealth * (1 + statModifier));
		break;

	case GroupEnums::Sniper:
		SetCurrentWeapon(ALaserSniper::CreateLaserSniper(GetWorld(), this));
		AddAbility(UAbility::CreateChannelledPresetAbility(this, AbilityEnums::Snipe, 2.5F, false, true));
		AddAbility(mCreatePresetAbility(AbilityEnums::CritBoost));
		SetDefenceModifier(0.0F + statModifier);
		SetHealthChangeModifier(1.0F + statModifier);
		blastResistance = AArmour::GetDeafultValue(ArmourGrades::Light);
		phsyicalResistance = AArmour::GetDeafultValue(ArmourGrades::MediumLight);
		energyResistance = AArmour::GetDeafultValue(ArmourGrades::Light);
		SetMaxHealth(lowHealth * (1 + statModifier));
		break;

	case GroupEnums::Support:
		SetCurrentWeapon(mCreatePresetWeapon(WeaponEnums::Shotgun, grade, quaility));
		AddAbility(USummonDamageDrone::CreateAbility(20, this));
		AddAbility(mCreatePresetAbility(AbilityEnums::Shield));
		AddAbility(mCreatePresetAbility(AbilityEnums::Disable));
		SetDefenceModifier(0.0F + statModifier);
		SetHealthChangeModifier(1.0F + statModifier);
		blastResistance = AArmour::GetDeafultValue(ArmourGrades::MediumLight);
		phsyicalResistance = AArmour::GetDeafultValue(ArmourGrades::Medium);
		energyResistance = AArmour::GetDeafultValue(ArmourGrades::MediumLight);
		SetMaxHealth(mediumHealth * (1 + statModifier));
		break;

	default:
		CreatePresetRole(GroupEnums::DPS);
		break;
	}

	SetHealth(GetMaxHealth());

	CreateArmour(phsyicalResistance, blastResistance, energyResistance, grade, quaility);
}
예제 #15
0
void AAmethystCharacter::OnRep_CurrentWeapon(AAmethystWeapon* LastWeapon)
{
	SetCurrentWeapon(CurrentWeapon, LastWeapon);
}
예제 #16
0
파일: Boss.cpp 프로젝트: belven/Mech_RPG
void ABoss::CreatePresetRole(TEnumAsByte<GroupEnums::Role> inRole, int32 grade, int32 quaility) {
	float statModifier = 0;
	float blastResistance = 5;
	float phsyicalResistance = 5;
	float energyResistance = 5;
	static float lowHealth = 9000;
	static float mediumHealth = lowHealth * 1.25;
	static float highHealth = mediumHealth * 1.25;

	StartingRole(inRole);
	Reset();

	switch (UMiscLibrary::GetDifficulty()) {
	case GameEnums::Easy:
		GetModifierForDifficulty(GameEnums::Hard);
		break;
	case GameEnums::Medium:
		GetModifierForDifficulty(GameEnums::Medium);
		break;
	case GameEnums::Hard:
		GetModifierForDifficulty(GameEnums::Easy);
		break;
	}

	switch (inRole) {
	case GroupEnums::DPS:
		SetCurrentWeapon(mCreatePresetWeapon(WeaponEnums::SMG, grade, quaility + 3));
		AddAbility(UDamageBoost::CreateAbility(7, this, 0.5));
		//AddAbility(UChannelledAbility::CreateChannelledAbility(this, UTimedHealthChange::CreateTimedHealthChange(this, 10.0F, 400.0F), 2, true, true));
		//AddAbility(UOrbitalStrike::CreateAbility(30, this, 350));
		AddAbility(UChannelledAbility::CreateChannelledAbility(this, UParticleBomb::CreateAbility(12.0F, this, 20.0F), 5.0F, false, true));
		SetDefenceModifier(0 + statModifier);
		SetHealthChangeModifier(1 + statModifier);
		SetMaxHealth(lowHealth * (1 + statModifier));
		energyResistance = AArmour::GetDeafultValue(ArmourGrades::Medium);
		phsyicalResistance = AArmour::GetDeafultValue(ArmourGrades::MediumLight);
		blastResistance = AArmour::GetDeafultValue(ArmourGrades::Medium);
		break;
	case GroupEnums::Tank:
		SetCurrentWeapon(mCreatePresetWeapon(WeaponEnums::Sword, grade, quaility + 3));
		AddAbility(UAbility::CreatePresetAbility(this, AbilityEnums::Taunt));
		AddAbility(UAbility::CreateChannelledPresetAbility(this, AbilityEnums::Stun, 2.5, false, true));
		SetDefenceModifier(0 + statModifier);
		SetHealthChangeModifier(1 + statModifier);
		SetMaxHealth(highHealth * (1 + statModifier));
		energyResistance = AArmour::GetDeafultValue(ArmourGrades::Heavy);
		phsyicalResistance = AArmour::GetDeafultValue(ArmourGrades::Heavy);
		blastResistance = AArmour::GetDeafultValue(ArmourGrades::Heavy);
		break;
	case GroupEnums::Sniper:
		SetCurrentWeapon(mCreatePresetWeapon(WeaponEnums::Sniper, grade, quaility + 3));
		AddAbility(UChannelledAbility::CreateChannelledAbility(this, USnipe::CreateAbility(7, this), 2.5F, false, true));
		SetDefenceModifier(0 + statModifier);
		SetHealthChangeModifier(1 + statModifier);
		SetMaxHealth(lowHealth * (1 + statModifier));
		energyResistance = AArmour::GetDeafultValue(ArmourGrades::Medium);
		phsyicalResistance = AArmour::GetDeafultValue(ArmourGrades::Light);
		blastResistance = AArmour::GetDeafultValue(ArmourGrades::Medium);
		break;
	case GroupEnums::Healer:
		SetCurrentWeapon(mCreatePresetWeapon(WeaponEnums::Bio_Repair, grade, quaility + 3));
		AddAbility(UHeal::CreateAbility(5, this, 12.0F));
		AddAbility(UDisable::CreateDisable(10, this, 5));
		SetDefenceModifier(0 + statModifier);
		SetHealthChangeModifier(1.5 + statModifier);
		SetMaxHealth(mediumHealth * (1 + statModifier));
		energyResistance = AArmour::GetDeafultValue(ArmourGrades::Medium);
		phsyicalResistance = AArmour::GetDeafultValue(ArmourGrades::MediumHeavy);
		blastResistance = AArmour::GetDeafultValue(ArmourGrades::Medium);
		break;
	default:
		CreatePresetRole(GroupEnums::DPS);
		break;
	}
	SetHealth(GetMaxHealth());

	CreateArmour(phsyicalResistance, blastResistance, energyResistance, grade, quaility);

}
예제 #17
0
void ANimModCharacter::OnRep_CurrentWeapon(ANimModWeapon* LastWeapon)
{
	SetCurrentWeapon(CurrentWeapon, LastWeapon);
}
예제 #18
0
void AShooterCharacter::OnRep_CurrentWeapon(AWeapon* LastWeapon)
{
	SetCurrentWeapon(CurrentWeapon, LastWeapon);
}