-
Notifications
You must be signed in to change notification settings - Fork 0
Step 6: Fallback Card Guide
The Fallback Cards system provides alternative card options when the weapon pool is empty or all weapons are at max level. This ensures players always have meaningful choices during level-ups.
- Health Restore: Heal the player (flat amount or percentage)
- Currency Bonus: Grant currency to the player
- XP Bonus: Grant additional experience points
- Stat Boost: Modify player stats (MaxHealth, MoveSpeed, etc.)
- Custom: Extensible for Blueprint implementations
- Right-click in Content Browser
- Navigate to: Miscellaneous → Data Asset
- Select: URFFallbackCardDataAsset
- Name it:
DA_FallbackHealthRestore
Open the data asset and configure:
Card Info:
├─ Card Name: "Health Restore"
├─ Card Description: "Restore 30 health"
└─ Card Icon: [Select texture]
Card Type:
└─ Fallback Type: Health Restore
Health Settings:
├─ Health Amount: 30.0
├─ Use Percentage: false
└─ Health Percentage: 0.3 (if using percentage)
- Select your Player Blueprint
- Find URFLevelUpSystem component
- In Fallback Cards category:
- Add element to Fallback Cards Pool
- Select your
DA_FallbackHealthRestore - Enable Use Fallback Cards (enabled by default)
- Play the game
- Level up when weapon pool is empty
- Fallback cards will appear as options
Restores player health.
Properties:
-
Health Amount: Flat health to restore (e.g., 30.0) -
Use Percentage: Use percentage instead of flat amount -
Health Percentage: Percentage of max health (0.0 - 1.0)
Example:
Flat: Health Amount = 30.0 → Restores 30 HP
Percentage: Health Percentage = 0.3 → Restores 30% of max HP
Grants currency to the player.
Properties:
-
Currency Amount: Amount of currency to grant (e.g., 100) -
Currency Type: Type of currency (e.g., "Gold", "Gems")
Example:
Currency Amount = 100
Currency Type = "Gold"
→ Grants 100 Gold
Grants additional experience points.
Properties:
-
XP Amount: Amount of XP to grant (e.g., 50)
Example:
XP Amount = 50
→ Grants 50 XP (may trigger another level up!)
Modifies player stats permanently.
Properties:
-
Stat Modifiers: Map of stat names to values
Example:
Stat Modifiers:
├─ "MaxHealth" → 10.0
├─ "MoveSpeed" → 5.0
└─ "Damage" → 2.0
For Blueprint-based custom implementations.
Note: Implement custom logic in Blueprint by listening to OnCardSelected event and checking for FallbackCard type.
When a level up occurs:
- Generate weapon cards (new weapons + upgrades)
-
Check if enough cards (need
CardsPerLevelUpcards) -
If not enough:
- Calculate needed cards:
NeededCards = CardsPerLevelUp - CurrentCards - Randomly select from
FallbackCardsPool - Add fallback cards to fill the gap
- Calculate needed cards:
Available Weapons: 0
Upgradeable Slots: 2
Fallback Cards: 3
Cards Per Level Up: 3
Result: 2 Upgrade Cards + 1 Fallback Card = 3 Cards ✅
Available Weapons: 0
Upgradeable Slots: 0
Fallback Cards: 3
Cards Per Level Up: 3
Result: 3 Fallback Cards ✅
Available Weapons: 5
Upgradeable Slots: 3
Fallback Cards: 3
Cards Per Level Up: 3
Result: 3 Random (Weapon/Upgrade) Cards
Fallback cards not used ✅
// Fallback Cards Settings
UPROPERTY(EditAnywhere, Category = "URF|Fallback Cards")
TArray<URFFallbackCardDataAsset*> FallbackCardsPool;
UPROPERTY(EditAnywhere, Category = "URF|Fallback Cards")
bool bUseFallbackCards = true;Properties:
-
Fallback Cards Pool: Array of fallback card data assets -
Use Fallback Cards: Enable/disable fallback cards system
Fallback cards use the same FURFCardOption structure:
struct FURFCardOption
{
EURFCardType CardType; // Will be "FallbackCard"
UURFWeaponDataAsset* WeaponData; // Null for fallback cards
URFFallbackCardDataAsset* FallbackData; // Contains card info
int32 WeaponSlotIndex; // -1 for fallback cards
};For each card in CardOptions:
If CardType == FallbackCard:
Display FallbackData->CardName
Display FallbackData->CardDescription
Display FallbackData->CardIcon
Else:
Display WeaponData->WeaponName
Display WeaponData->Description
Display WeaponData->Icon
Event OnLevelUpCardSelection(CardOptions)
├─ For Each (CardOptions)
│ ├─ Switch on CardType
│ │ ├─ Case NewWeapon:
│ │ │ └─ Create Weapon Card Widget
│ │ ├─ Case UpgradeWeapon:
│ │ │ └─ Create Upgrade Card Widget
│ │ └─ Case FallbackCard:
│ │ └─ Create Fallback Card Widget
│ │ ├─ Set Text: FallbackData->CardName
│ │ ├─ Set Description: FallbackData->CardDescription
│ │ └─ Set Icon: FallbackData->CardIcon
Name: "Healing Touch"
Description: "Restore 30% of your maximum health"
Type: Health Restore
Use Percentage: true
Health Percentage: 0.3
Name: "Treasure Chest"
Description: "Gain 100 gold coins"
Type: Currency Bonus
Currency Amount: 100
Currency Type: "Gold"
Name: "Knowledge Boost"
Description: "Gain 50 experience points"
Type: XP Bonus
XP Amount: 50
Name: "Permanent Power"
Description: "Increase max health by 10 and move speed by 5"
Type: Stat Boost
Stat Modifiers:
- MaxHealth: 10.0
- MoveSpeed: 5.0
- Create diverse fallback cards: Mix health, currency, XP, and stat boosts
- Balance values: Ensure fallback cards are as valuable as weapon upgrades
- Use clear names: Make it obvious what each card does
- Add icons: Visual feedback improves player experience
- Test edge cases: Test with empty weapon pool and max level weapons
Check:
-
Use Fallback Cardsis enabled -
Fallback Cards Poolis not empty - Weapon pool is actually empty or all weapons are max level
Check:
- Required component exists on player (HealthComponent, CurrencyComponent, etc.)
- Enable
Debug Loggingin Level Up System to see logs - Check console for warnings
Check:
- UI is checking
CardTypeand using correct data source - For fallback cards, use
FallbackDatanotWeaponData
New Files:
├─ URFFallbackCardDataAsset.h
└─ URFFallbackCardDataAsset.cpp
Modified Files:
├─ URFLevelUpSystem.h
└─ URFLevelUpSystem.cpp
Fallback cards require these components:
-
URFHealthComponent(for Health Restore) -
URFCurrencyComponent(for Currency Bonus) -
URFExperienceComponent(for XP Bonus) -
URFPlayerStatsComponent(for Stat Boost)
If a component is missing, the card effect will be skipped with a warning log.
Create custom fallback card types in Blueprint:
- Set
Fallback Typeto Custom - Listen to
OnCardSelectedevent - Check if
CardType == FallbackCard - Implement custom logic based on
FallbackData
Modify the fallback pool at runtime:
// Add fallback card
LevelUpSystem->FallbackCardsPool.Add(NewFallbackCard);
// Remove fallback card
LevelUpSystem->FallbackCardsPool.Remove(OldFallbackCard);
// Clear pool
LevelUpSystem->FallbackCardsPool.Empty();