void AShooterCharacter::SpawnDefaultInventory() { if (Role < ROLE_Authority) { return; } int32 NumWeaponClasses = DefaultInventoryClasses.Num(); for (int32 i = 0; i < NumWeaponClasses; i++) { if (DefaultInventoryClasses[i]) { FActorSpawnParameters SpawnInfo; SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn; AWeapon* NewWeapon = GetWorld()->SpawnActor<AWeapon>(DefaultInventoryClasses[i], SpawnInfo); AddWeapon(NewWeapon); } } // equip first weapon in inventory if (Inventory.Num() > 0) { EquipWeapon(Inventory[0]); } }
void AAmethystCharacter::SpawnDefaultInventory() { if (Role < ROLE_Authority) { return; } // @hack to remove rocket launcher int32 NumWeaponClasses = DefaultInventoryClasses.Num(); for (int32 i = 0; i < NumWeaponClasses; i++) { if (DefaultInventoryClasses[i]) { FActorSpawnParameters SpawnInfo; SpawnInfo.bNoCollisionFail = true; AAmethystWeapon* NewWeapon = GetWorld()->SpawnActor<AAmethystWeapon>(DefaultInventoryClasses[i], SpawnInfo); AddWeapon(NewWeapon); } } // equip first weapon in inventory if (Inventory.Num() > 0) { EquipWeapon(Inventory[0]); } }
void SpellHit(Unit* target, const SpellInfo* spell) { if (spell->Id == SPELL_PICK_WEAPON) { ResetWeapon(); EquipWeapon(); events.ScheduleEvent(EVENT_PICK_WEAPON, 30000); } }
void ASCharacter::OnPrevWeapon() { if (Inventory.Num() >= 2) // TODO: Check for weaponstate. { const int32 CurrentWeaponIndex = Inventory.IndexOfByKey(CurrentWeapon); ASWeapon* PrevWeapon = Inventory[(CurrentWeaponIndex - 1 + Inventory.Num()) % Inventory.Num()]; EquipWeapon(PrevWeapon); } }
void AShooterCharacter::OnNextWeapon() { if (Inventory.Num() >= 2 && (CurrentWeapon == NULL || CurrentWeapon->GetCurrentState() != EWeaponState::Equipping)) { const int32 CurrentWeaponIdx = Inventory.IndexOfByKey(CurrentWeapon); AWeapon* NextWeapon = Inventory[(CurrentWeaponIdx + 1) % Inventory.Num()]; EquipWeapon(NextWeapon); } }
void AAmethystCharacter::OnPrevWeapon() { AamethystforestPlayerController* MyPC = Cast<AamethystforestPlayerController>(Controller); if (MyPC && MyPC->IsGameInputAllowed()) { if (Inventory.Num() >= 2 && (CurrentWeapon == NULL || CurrentWeapon->GetCurrentState() != EWeaponState::Equipping)) { const int32 CurrentWeaponIdx = Inventory.IndexOfByKey(CurrentWeapon); AAmethystWeapon* PrevWeapon = Inventory[(CurrentWeaponIdx - 1 + Inventory.Num()) % Inventory.Num()]; EquipWeapon(PrevWeapon); } } }
void DoAction(int32 action) override { switch (action) { case ACTION_EQUIP_DEFAULT: case ACTION_EQUIP_INFERNO_BLADE: case ACTION_EQUIP_DECIMATION_BLADE: EquipWeapon(action); break; default: break; } }
void ASCharacter::AddWeapon(class ASWeapon* Weapon) { if (Weapon && Role == ROLE_Authority) { Weapon->OnEnterInventory(this); Inventory.AddUnique(Weapon); // Equip first weapon in inventory if (Inventory.Num() > 0 && CurrentWeapon == nullptr) { EquipWeapon(Inventory[0]); } } }
void ASCharacter::OnPrevWeapon() { if (CarriedObjectComp->GetIsCarryingActor()) { CarriedObjectComp->Rotate(0.0f, -1.0f); return; } if (Inventory.Num() >= 2) // TODO: Check for weaponstate. { const int32 CurrentWeaponIndex = Inventory.IndexOfByKey(CurrentWeapon); ASWeapon* PrevWeapon = Inventory[(CurrentWeaponIndex - 1 + Inventory.Num()) % Inventory.Num()]; EquipWeapon(PrevWeapon); } }
void AWeaponEssentialsCharacter::NextWeapon() { if (Inventory[CurrentWeapon->WeaponConfig.Priority]->WeaponConfig.Priority != 2) { if (Inventory[CurrentWeapon->WeaponConfig.Priority + 1] == NULL) { for (int32 i = CurrentWeapon->WeaponConfig.Priority + 1; i < Inventory.Num(); i++) { if (Inventory[i] && Inventory[i]->IsA(AWeapon::StaticClass())) { EquipWeapon(Inventory[i]); } } } else { EquipWeapon(Inventory[CurrentWeapon->WeaponConfig.Priority + 1]); } } else { EquipWeapon(Inventory[CurrentWeapon->WeaponConfig.Priority]); } }
void AWeaponEssentialsCharacter::PrevWeapon() { if (Inventory[CurrentWeapon->WeaponConfig.Priority]->WeaponConfig.Priority != 0) { if (Inventory[CurrentWeapon->WeaponConfig.Priority - 1] == NULL) { for (int32 i = CurrentWeapon->WeaponConfig.Priority - 1; i >= 0; i--) { if (Inventory[i] && Inventory[i]->IsA(AWeapon::StaticClass())) { EquipWeapon(Inventory[i]); } } } else { EquipWeapon(Inventory[CurrentWeapon->WeaponConfig.Priority - 1]); } } else { EquipWeapon(Inventory[CurrentWeapon->WeaponConfig.Priority]); } }
void ASCharacter::OnEquipSecondaryWeapon() { if (Inventory.Num() >= 2) { /* Find first weapon that uses secondary slot. */ for (int32 i = 0; i < Inventory.Num(); i++) { ASWeapon* Weapon = Inventory[i]; if (Weapon->GetStorageSlot() == EInventorySlot::Secondary) { EquipWeapon(Weapon); } } } }
void AAgent::SelectWeapon(float Dist) { // Get the currently equipped weapon ABaseWeapon* CurrentWeapon = GetCurrentWeapon(); // New weapon to change to (Initialize as current weapon so it is not NULL/not initialized) ABaseWeapon* NewWeapon = CurrentWeapon; double CurrentDesirability = CurrentWeapon->CalculateDesirability(Dist); // The desirability of the most desirable weapon at the moment double TempDesirability = 0.0; if ((CurrentWeapon && NewWeapon) != NULL) { for (auto &it : Weapons) { if (it != NULL) { // Calculate the desirability of this weapon double OtherDesirability = it->CalculateDesirability(Dist); // If the this weapon is more desirable than the currently equipped weapon if (OtherDesirability > CurrentDesirability) { // Check for the first iteration of the Weapons array if (TempDesirability == 0.0) { // This is currently the most desirable weapon TempDesirability = OtherDesirability; // Set as new weapon to equip NewWeapon = it; } // Otherwise if this weapon's desirability is greater than the previous most desirable weapon else if (OtherDesirability > TempDesirability) { // This is the most desirable weapon TempDesirability = OtherDesirability; // Set this as the new weapon to equip NewWeapon = it; }// If a previous weapon in the array has a higher desirability score, do nothing } } } // If the current weapon isn't the same as the new weapon then // the weapon needs to be changed AND the currently equipped // weapon's desirability is less than 30 if ((CurrentWeapon != NewWeapon) && (CurrentDesirability < 30.0f)) // Equip the weapon EquipWeapon(NewWeapon); } }
void AShooterCharacter::OnEquipPrimaryWeapon() { if (Inventory.Num() >= 1) { /* Find first weapon that uses primary slot. */ for (int32 i = 0; i < Inventory.Num(); i++) { AWeapon* Weapon = Inventory[i]; if (Weapon->GetStorageSlot() == EInventorySlot::Hands) { EquipWeapon(Weapon); } } } }
void ALonelyMenCharacter::SpawnDefaultInventory() { int32 InventoryCount = this->DefaultInventoryClasses.Num(); for (int32 i = 0; i < InventoryCount;i++) { if (DefaultInventoryClasses[i]) { FActorSpawnParameters SpawnInfo; SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButDontSpawnIfColliding; ALMWeapon* NewWeapon = GetWorld()->SpawnActor<ALMWeapon>(DefaultInventoryClasses[i], SpawnInfo); AddWeapon(NewWeapon); } } if (Inventory.Num()>0) { EquipWeapon(Inventory[0]); } }
void ASCharacter::OnEquipSecondaryWeapon() { if (CarriedObjectComp->GetIsCarryingActor()) { CarriedObjectComp->Rotate(-1.0f, 0.0f); return; } if (Inventory.Num() >= 2) { /* Find first weapon that uses secondary slot. */ for (int32 i = 0; i < Inventory.Num(); i++) { ASWeapon* Weapon = Inventory[i]; if (Weapon->GetStorageSlot() == EInventorySlot::Secondary) { EquipWeapon(Weapon); } } } }
void ANimModCharacter::SpawnDefaultInventory() { if (Role < ROLE_Authority) { return; } //Initialize the empty array of our inventory. int32 maxFlatInventoryCount = 10 * MAX_SLOTS_PER_INVENTORY_SLOT; for (int32 i = 0; i < maxFlatInventoryCount; ++i) Inventory.Add(nullptr); int32 NumWeaponClasses = DefaultInventoryClasses.Num(); for (int32 i = 0; i < NumWeaponClasses; i++) { if (DefaultInventoryClasses[i]) { FActorSpawnParameters SpawnInfo; SpawnInfo.bNoCollisionFail = true; ANimModWeapon* NewWeapon = GetWorld()->SpawnActor<ANimModWeapon>(DefaultInventoryClasses[i], SpawnInfo); AddWeapon(NewWeapon); } } for (auto *weapon : Inventory) { if (weapon != nullptr) { EquipWeapon(weapon); break; } } // equip first weapon in inventory /*if (Inventory.Num() > 0) { if (Inventory[0].Num() > 0) EquipWeapon(Inventory[0][0]); }*/ }
void AMainCharacter::SelectWeapon1() { EquipWeapon(0); }
void AsbrPlayer::OnOnePressed() { if (Inventory.Num() >= 1) EquipWeapon(Inventory[0]); }
void ANimModCharacter::UseSlot(int32 slot) { //Make sure we have some weapons if (Inventory.Num() == 0) return; //Make sure the slot has weapons if (!DoesSlotHaveWeapons(slot)) return; int32 slotStart, slotEnd; GetSlotStartAndEnd(slot, slotStart, slotEnd); if (CurrentWeapon == nullptr || slot != CurrentWeapon->GetInventorySlot()) { //Find the first weapon in this slot and assign it. ANimModWeapon *weapon = nullptr; for( int32 index = slotStart; index < slotEnd; ++index) { weapon = Inventory[index]; if (weapon) { EquipWeapon(weapon); break; } } } else { //Determine if we're cycling through a slot, or switching to a new one. int32 currentWeaponIndex = GetWeaponInventoryIndex(CurrentWeapon); ANimModWeapon *newWeapon = nullptr; //Cycling. Find the next weapon in this slot for (int32 index = currentWeaponIndex + 1; index < slotEnd; ++index) { newWeapon = Inventory[index]; if (newWeapon != nullptr) break; } //No weapons in this slot after our current weapon? Check the weapons before this weapon if (newWeapon == nullptr && currentWeaponIndex != slotStart) { for (int32 index = slotStart; index < currentWeaponIndex; ++index) { newWeapon = Inventory[index]; if (newWeapon != nullptr) break; } } //Did we find anything? if (newWeapon != nullptr) EquipWeapon(newWeapon); /*if (slot == CurrentWeapon->GetInventorySlot()) { }*/ //else //{ // //Find the first weapon in this slot and assign it. // ANimModWeapon *weapon = nullptr; // for (int index = slotStart; index < slotEnd; ++index) // { // weapon = Inventory[index]; // if (weapon) // { // EquipWeapon(weapon); // break; // } // } //} } }
void AsbrPlayer::OnTwoPressed() { if (Inventory.Num() >= 2) EquipWeapon(Inventory[1]); }
void Reset() override { firelands_bossAI::Reset(); _canYellKilledPlayer = true; EquipWeapon(EQUIP_DEFAULT); }
void AsbrPlayer::OnThreePressed() { if (Inventory.Num() >= 3) EquipWeapon(Inventory[2]); }
void AAmethystCharacter::ServerEquipWeapon_Implementation(AAmethystWeapon* Weapon) { EquipWeapon(Weapon); }
void ANimModCharacter::ServerEquipWeapon_Implementation(ANimModWeapon* Weapon) { EquipWeapon(Weapon); }
void AMainCharacter::SelectWeapon3() { EquipWeapon(2); }
void ASCharacter::ServerEquipWeapon_Implementation(ASWeapon* Weapon) { EquipWeapon(Weapon); }
/* ======================== idMenuScreen_PDA_Inventory::HandleAction ======================== */ bool idMenuScreen_PDA_Inventory::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) { if ( menuData == NULL ) { return true; } if ( menuData->ActiveScreen() != PDA_AREA_INVENTORY ) { return false; } widgetAction_t actionType = action.GetType(); const idSWFParmList & parms = action.GetParms(); switch ( actionType ) { case WIDGET_ACTION_JOY3_ON_PRESS: { EquipWeapon(); return true; } case WIDGET_ACTION_GO_BACK: { menuData->SetNextScreen( PDA_AREA_INVALID, MENU_TRANSITION_ADVANCE ); return true; } case WIDGET_ACTION_START_REPEATER: { idWidgetAction repeatAction; widgetAction_t repeatActionType = static_cast< widgetAction_t >( parms[ 0 ].ToInteger() ); assert( parms.Num() == 2 ); repeatAction.Set( repeatActionType, parms[ 1 ] ); menuData->StartWidgetActionRepeater( widget, repeatAction, event ); return true; } case WIDGET_ACTION_SELECT_PDA_ITEM: { if ( itemList.GetMoveDiff() > 0 ) { itemList.MoveToIndex( itemList.GetMoveToIndex(), true ); } int index = parms[0].ToInteger(); if ( index != 0 ) { itemList.MoveToIndex( index ); Update(); } return true; } case WIDGET_ACTION_STOP_REPEATER: { menuData->ClearWidgetActionRepeater(); return true; } case WIDGET_ACTION_SCROLL_HORIZONTAL: { if ( itemList.GetTotalNumberOfOptions() <= 1 ) { return true; } if ( itemList.GetMoveDiff() > 0 ) { itemList.MoveToIndex( itemList.GetMoveToIndex(), true ); } int direction = parms[0].ToInteger(); if ( direction == 1 ) { if ( itemList.GetViewIndex() == itemList.GetTotalNumberOfOptions() - 1 ) { return true; } else { itemList.MoveToIndex( 1 ); } } else { if ( itemList.GetViewIndex() == 0 ) { return true; } else { itemList.MoveToIndex( ( itemList.GetNumVisibleOptions() / 2 ) + 1 ); } } Update(); return true; } } return idMenuWidget::HandleAction( action, event, widget, forceHandled ); }
void AMainCharacter::SelectWeapon2() { EquipWeapon(1); }