Conditions, costs and rewards
PulseGameplay uses the condition, cost and reward lists of Pulse Foundation (FPulseConditionList, FPulseCostList, FPulseRewardList; see the page “Conditions, costs and rewards” of the Pulse Foundation docs) and adds entries for its own data: items, equipment, loot, attributes, combat and interactions. Every list of every Pulse plugin can use them: a door that needs a key, a skill that costs items, a quest reward that rolls a loot table, a dialog choice that needs a sword in the hand.
Where PulseGameplay uses the lists
| Where | Lists | Context |
|---|---|---|
| Interactable component (Interaction system) | Conditions, Costs | The interactor is Player and Instigator, the owner of the component Target, the component Source. |
| Recipe (Crafting) | Conditions | The crafter is Player and Instigator, the owner of the station Target, the recipe Source, the rounds Amount; FPulseCraftingContext is the extra data. |
| Loot table entry (Loot) | Conditions | Player, Tags and Source of the roll; FPulseLootContext is the extra data. |
| Melee and ranged ability, weapon trait (Combat and inventory) | AttackCosts, Costs | The attacker’s avatar is Player and Instigator, the weapon, attack or shot Source; FPulseAttackCostExtra (the ability’s spec handle) is the extra data. |
Conditions
| Condition | Category | Module | Passes when |
|---|---|---|---|
Has Item (FPulseCondition_HasItem) | Items | PulseInventory | The player has Count items of Item, or items with ItemTag; with bIncludeEquipped equipped stacks count too, with bIncludeLent lent stacks (items a skill lends, see lent items). It uses nothing up. |
Has Equipment (FPulseCondition_HasEquipment) | Equipment | PulseInventory | Something is equipped in Slot (or in any slot when it is empty); with Item or ItemTag it must be that item. |
Loot Level (FPulseCondition_LootLevel) | Loot | PulseInventory | The level of the loot roll is at least MinLevel and at most MaxLevel (0 = no upper limit). Outside of loot rolls the level is 0. |
Alive (FPulseCondition_Alive) | Combat | PulseCombat | The actor is alive (for the player: its pawn); with bAlive off, when it is dead. |
Cooldown (FPulseCondition_InteractCooldown) | Interaction | PulseAbility | Seconds have passed since the interactable component (the Source of the context) last completed an interaction. Line while it waits: Text (“Ready in {Seconds} s”). |
Pulse Foundation adds the general ones (All Of, Any Of, Not, Context Tags, Actor Has Tags, Actor Tag Query, Actor Is Class, Compare Amount, Blueprint Condition) and the attribute entries: the condition Attribute (FPulseCondition_Attribute, a Pulse attribute such as Pulse.Stat.Health of an actor of the context compares to a value; it replaces Attribute Value of PulseAttributes) and the reward Change Attribute (FPulseReward_ChangeAttribute; Op Add on Pulse.Stat.Health replaces Heal). Both reach the health and stamina sets of PulseGameplay through the GAS adapter. Conditions that need the inventory or ability system of a player that is not on this machine answer Unknown on clients; the server decides.
Costs
| Cost | Module | Pays |
|---|---|---|
Items (FPulseCost_Items) | PulseInventory | Takes Count items of Item, or items with ItemTag, from the player’s inventory first and, with bIncludeEquipped, then from equipped stacks (a quiver). Refunds give an Item back (items that do not fit are dropped at the pawn; without a player at the Location of the context, e.g. a destroyed building piece); a cost by tag gives back RefundItem, if set. Lent stacks never pay; worn stacks (durability below the maximum) pay only when Allow Worn Items To Leave of the inventory settings is on, and unworn stacks always go first; bound stacks pay (a key that is used up). Inside an open Pulse::Inventory::FItemCostLedger the stacks taken are recorded with their instance traits and the key of the cost that took them (its Item and ItemTag), and a refund gives exactly those back (a bound key comes back bound, a worn sword worn), only the rest as new items; a refund takes only the records of its own key, oldest first, so each cost gets its own stacks back, also when a cost by tag (Food) matches the item of an Items cost (Meat) and also when it gives back less than it took (the rounds of a crafting cancel that did not run); crafting keeps the records with the job for a cancel. The take is one change per holder (inventory, equipment), applied together: one event pass each, all or nothing. With FPulseItemCostExtra as extra data of the context the cost pays from (and refunds into) that inventory instead of the player’s first one. The lines show icon, what the player has and what it costs. |
Weapon Item (FPulseCost_WeaponItem) | PulseCombatInventory | Takes Count from the stack of the weapon that granted the attack (bombs, throwing knives). Only for attacks; elsewhere it costs nothing. |
Stamina, mana and other attributes are paid with the Attribute cost of Pulse Foundation (FPulseCost_Attribute): Amount of Attribute from an actor of the context (default Instigator), through its attribute source, so it works with the health and stamina sets of PulseGameplay (GAS adapter) and with the Pulse Attributes component alike. Attacks (AttackCosts) and interactables (Costs) use it for stamina.
Fraction of the cost context scales the item count (payment stages of a building, a part refund); payments round up, refunds round down (see Pulse Foundation).
Rewards
| Reward | Module | Grants |
|---|---|---|
Give Items (FPulseReward_GiveItems) | PulseInventory | Count items of Item into the player’s inventory; with bDropWhenFull what does not fit is dropped at the pawn. |
Take Items (FPulseReward_TakeItems) | PulseInventory | Takes items like the Items cost, without a check (a quest that takes the letter it asked for); lent stacks stay. |
Roll Loot Table (FPulseReward_RollLoot) | PulseInventory | Rolls Table with Level and the tags, source and player of the context, puts the drops into the player’s inventory (with their random stats) and drops the rest with bDropWhenFull. |
Rewards are granted on the authority.
Helpers for own entries
Pulse::Inventory (PulseInventory, Conditions/PulseInventoryConditions.h) has the functions the item entries use:
| Function | What it does |
|---|---|
CountPlayerItems(Context, Item, ItemTag, bIncludeEquipped, bOutFound, bIncludeLent, bIncludeWorn) | Items of the player in inventory (and equipment), lent stacks only with bIncludeLent, worn stacks only with bIncludeWorn (default on; the Items cost passes CanWornItemsLeave()); bOutFound is false when the player has neither here. |
TakePlayerItems(Context, Item, ItemTag, Count, bIncludeEquipped, bIncludeWorn) | Takes items, inventory first, unworn stacks before worn ones (worn only with bIncludeWorn), never lent stacks; returns how many. An open FItemCostLedger records what it took. |
FItemCostLedger | A scope (game thread) that records the stacks TakePlayerItems takes, each as an FPulseItemCostRecord with the key of its cost (Item, ItemTag), and lets the refund of an Items cost give them back with their instance traits; open it with records kept from earlier to refund those. Withdraw hands out the records of exactly the refunding cost’s key first, oldest first, then records without a key (older save data) whose item matches. Interaction costs, attack costs, repairs and crafting pay inside one. |
IsLent(Traits) | Whether the instance traits of a stack mark it as lent (FPulseItemTrait::IsLent). |
GivePlayerItems(Context, Item, Count, bDropWhenFull, InstanceTraits) | Adds items (with these instance traits), drops the rest at the pawn (without a player at the Location of the context); returns how many were added. |
MatchesItem(Definition, Item, ItemTag), GetItemEntryName(Item, ItemTag) | Whether a definition is the item (or has the tag), and its name for lines. |
For own entries on attributes take the actor of the context and Pulse::Attributes::FindSource (Pulse Foundation); it finds the source on the pawn or the player state. Write own entries in C++ by deriving from FPulseCondition, FPulseCost or FPulseReward (Pulse Foundation); they show up in every list with their category.