WCGASCustomCostFormula

Purpose:

This is an abstract base class that allows you to create custom cost calculations for Souls-like attribute purchasing systems. Instead of using built-in cost formulas, you inherit from this class to implement your own unique pricing logic for attribute upgrades.

What It Does:

When you create a Blueprint or C++ child class and override the Calculate Cost For Purchase function, this system:

  1. Provides complete purchase context - current attribute value, total purchases made, the specific attribute being upgraded, the actor making the purchase, and the spending rule configuration
  2. Runs your custom pricing logic every time a player attempts to purchase an attribute upgrade or the UI needs to display the next cost
  3. Supports sophisticated designs - class-based multipliers (Warriors pay less for Strength), soft caps with exponential scaling after thresholds, level-gated pricing, diminishing returns, or any formula you can implement
  4. Integrates with spending rules - access to base costs, multipliers, and other configuration from your SpendingRule data
  5. Works with the purchase system to validate costs and deduct resources automatically

How It's Used:

  1. Create a Blueprint child class (e.g., BP_ClassBasedCostFormula) or C++ subclass
  2. Override Calculate Cost For Purchase event/function
  3. Implement your custom logic using the Context parameter (which contains CurrentPurchaseCount, TotalPurchaseCount, Actor reference, SpendingRule data, AttributeTag)
  4. Assign your custom formula to your Leveling Rules Data Asset → CustomCostFormula property (in Souls-like spending rules)
  5. The system automatically calls it whenever the UI updates or a purchase is attempted

Designer-Friendly Example:

You want a Warrior class to pay 50 XP per Strength upgrade but 200 XP per Intelligence upgrade, while a Mage has the opposite pricing. You also want costs to increase exponentially after 50 total attribute purchases (soul level). You: