Shipyard and repairs (PulseGameplay)

Pulse Water does not depend on PulseGameplay. The separate plugin PulseWaterGameplayBridge connects boats to the interaction, inventory and crafting of PulseGameplay: players build a boat at a shipyard, sail it, and patch its leaks and repair its hull with items.

Setup

  1. Enable PulseWater, PulseGameplay and PulseWaterGameplayBridge.
  2. Players need what PulseGameplay interactions and crafting need: the interact ability (the replicated one for multiplayer), an inventory and a Pulse Crafting component (the cheat PulseGameplayGrant gives all of them to any pawn).
  3. Optional: the Workflow tab of Water (or Core) has the step of the bridge Add the repair interaction to every boat. Without it, boats get the repair interaction where their Blueprint has the component.

Boats as items

The item trait Boat (FPulseItemTrait_Boat) makes an item a boat: Boat Class is the boat Blueprint (a child of APulseWaterBoat with its definition), Upgrades the upgrades it starts with. Give boat items a Max Stack Size of 1. A recipe of PulseGameplay crafting builds a boat when its output is a boat item; give it the station tag Pulse.Crafting.Station.Shipyard (Required Station Tags), so only shipyards build it.

Shipyards

A shipyard is a crafting station with a slipway on the water:

  • Pulse Water Shipyard (APulseWaterShipyard) is a ready actor: a platform (a flat cube until you give it a mesh), a volume the interact ability finds, the Slipway (8 m out and 1 m below the platform), a crafting station with the shipyard tag and the Shipyard component. Place it at the shore so the slipway lies on the water, and set the Recipe of its Shipyard component.
  • Or add a Pulse Crafting Station and a Pulse Water Shipyard component (UPulseWaterShipyardComponent) to an actor of your own. The slipway is the scene component named Slipway Component Name on the actor, else Slipway Offset. The actor needs a primitive the interact query overlaps (see Interaction volumes).

The interaction of the shipyard:

The player The prompt What happens (server)
carries a boat item “Launch Sail Boat” The boat is spawned at the slipway and the item is taken.
carries none “Build Sail Boat”, the ingredients of the recipe as costs StartCrafting(Recipe, 1, Station): the ingredients are taken, the round runs at the station.

When a round of a recipe is crafted at the station of the shipyard, the shipyard takes the boat item of the recipe out of the inventory it went into and launches the boat (Launch Crafted Boats). With Snap To Water the boat starts on the water surface at the slipway (ocean, lakes, rivers). The slipway must be free: while a boat lies within Slipway Clearance, the item stays in the inventory and the prompt says “A boat lies on the slipway”; the player launches it later. OnBoatLaunched (and OnBoatLaunchedNative) fires on the server for every launched boat; LaunchBoatItem and LaunchBoat launch boats from your own code.

The reasons of the crafting rules (missing ingredients, too far, queue full) reach the prompt unchanged. Conditions and Costs of the interactable apply on top (a fee for the shipwright).

Patching leaks and repairing the hull

Pulse Water Boat Repair (UPulseWaterBoatRepairComponent) on a boat makes its hull repairable by holding the interaction:

  • Patch leak (first): the leak nearest to the player within Leak Range. Holding for Hold Duration (2 s) closes Patch Area of it (0: the whole hole) and pays Leak Costs, for example an Items cost with one plank.
  • Repair hull (with Repair Hull, when no leak is in reach and the hull is damaged): holding for Hull Hold Duration (3 s) restores Hull Repair Amount health and pays Hull Costs.

The prompt names the action and its costs; when the player cannot pay, it is unavailable with the text of the cost (“Needs 1x Wood”). The action is chosen when the interaction starts and runs on the server when it completes: the costs are paid all or nothing, then RepairLeaks or RepairHull of the hull with the player as instigator, so OnLeaksRepaired and the attribute events of the hull name who repaired. A sunk boat is not repaired.

Add the component to a boat Blueprint and set its costs there, or turn on the automatic component (Project Settings > Pulse > Water > Core, Repair Component): every boat gets it when it spawns. Point Component at a Blueprint child of the component to give the automatic one costs.

Breath bar

The bridge can give every player the breath of swimming and show it as a bar of the Status HUD of PulseGameplay. Turn on Breath in Project Settings > Pulse > Water > Core:

Setting Default Meaning
bBreath off Registers Pulse.Stat.Breath for players (Pulse::Water::Breath::MakeBreathDefinition) and the bar PulseWater.Breath.
BreathSeconds 30 Seconds under water from full to 0.
BreathRefillSeconds 5 Seconds above the surface from 0 to full.
DrowningDamagePerSecond 10 Health lost per second at 0 breath (Pulse.Water.Debuff.Drowning).

Breath falls while the player has the owner tag Pulse.Water.State.HeadUnderWater, which the swim movement of Pulse Water gives on the server. At 0 health falls until the head is above the surface; at health 0 the attribute source sends Depleted, and PulseGameplay combat (or your own rule) decides what follows. The bar hides while the pawn has no breath (Hide Without Attribute). An entry Pulse.Stat.Breath in the attribute profile of the player wins over the settings; the bar then shows that entry. Changes in the settings apply to pawns that start after them.

Interaction volumes

The sphere query of the interact ability (default settings) only overlaps World Static objects, and the hull of a boat is a Vehicle. So the repair component adds a box around the hull at BeginPlay on every machine (Create Interact Volume, Volume Margin), and the shipyard actor has a volume of its own. Both are World Static, query only and overlap World Dynamic only: pawns, traces and the navigation ignore them. Pulse::WaterGameplay::ConfigureInteractVolume sets up a primitive of your own the same way.

Multiplayer and saving

Building, launching and repairing happen on the server; the components replicate, so the replicated interact ability sends the interaction of a client to the server. Prompts on clients read the replicated leaks, hull health and inventory. Launched boats are boats spawned at runtime: the boats save themselves (Saving), and a load spawns them again. The components keep no state of their own.

The shipyard actor sleeps on the network (net dormancy): a placed shipyard is not sent until it changes, a spawned one sleeps after its first replication, and a change of its station settings wakes it once. Interactions still reach the server, since they go through the interact ability of the player. If you add replicated state to a shipyard, call Flush Net Dormancy after changing it on the server. Boats do not sleep: they move all the time.

Example

/PulseWaterGameplayBridge/Examples/LV_PulseWaterGameplay_Example is the coast of the PulseWater example with a shipyard: the sail boat costs 12 wood (the wood of the PulseGameplay example) and takes 8 seconds, the example sail boat (BP_PulseWaterGameplayExample_SailBoat) has the repair interaction (a patch 1 wood, a hull repair 2 wood for 25 health). Play Example for Water Gameplay in the Pulse window opens it; PulseGameplayGrant and PulseWaterGameplayGrant (30 wood) give the player what it needs. PulseWaterBoatDamage makes leaks to patch. The bridge builds the content with Tools/make_shipyard_example.py.

Cheats

Cheat What it does
PulseWaterGameplayGrant [count] Gives the player wood of the PulseGameplay example (default 30) for the example boat and its repairs (server). Needs an inventory: run PulseGameplayGrant first.

The spec of the bridge is PulseWaterGameplayBridge (groups Shipyard and Repair).


This site uses Just the Docs, a documentation theme for Jekyll.