Wobycommon
Based on game build 714014 | Last updated: 2026-02-27
Overview
wobycommon.lua is a shared utility module for the woby companion's AI behavior system. It defines reusable behavior functions and node factories used in Woby's state graphs and brain configurations. The module does not implement a component class itself but exposes helper functions that drive Woby’s interactions with players (particularly Walter), containers, items, and active minigames. It integrates heavily with components like container, inventory, follower, skilltreeupdater, and custom woby_commands_classified to determine eligibility and priority of actions such as item fetching, foraging, ammo retrieval, courier delivery, and sit/idle behaviors.
Usage example
Below is an example of how this module is typically referenced in a state graph or brain file to construct behavior trees for Woby:
local WobyCommon = require("brains/wobycommon")
local function MakeStateGraph(inst)
local sg = StateGraph("woby_common_sg")
sg:AddState("Fetching", {
OnEnter = function(inst)
inst.sg:GoToState("Fetching")
end,
OnExit = function(inst)
inst.sg:ClearStateTag("fetching")
end,
})
sg:SetRoot("Fetching")
return sg
end
local function OnPostInit(inst)
-- Example: Attach behavior logic using WobyCommon node factories
inst:AddBehaviourNode(WobyCommon.FetchingActionNode(inst))
inst:AddBehaviourNode(WobyCommon.ForagerNode(inst))
inst:AddBehaviourNode(WobyCommon.SitStillNode(inst))
end
Dependencies & tags
Components used:
container, follower, inventory, inventoryitem, minigame, minigame_participator, playercontroller, skilltreeupdater, trap, trader
Tags:
No tags are added or removed by this module itself. It checks for "outofreach", "recoverableammo", "largecreature", "slingshot" on items and "walter_woby_itemfetcher" / "walter_woby_foraging" in the skilltree.
Properties
This module does not define a component class, so there are no persistent properties initialized. All functions are pure, stateless utilities or factory functions returning behavior nodes.
Main functions
OwnerIsClose(inst, distance)
- Description: Returns
trueif the owner (stored ininst._playerlink) is within the givendistanceofinst. - Parameters:
inst: The Woby entity instance.distance(number): Threshold distance for proximity check.
- Returns:
trueifinst._playerlinkexists and is within range; otherwisefalse. - Error states: Returns
falseifinst._playerlinkisnilor invalid.
IsWheelOpen(inst)
- Description: Checks if the player is currently interacting with Woby's command wheel.
- Parameters:
inst: The Woby entity instance.
- Returns:
trueifinst.woby_commands_classified:IsClientWheelOpen()returnstrue; otherwisefalse. - Error states: Returns
falseifwoby_commands_classifiedcomponent is missing.
FindPickupableItem_ExtraFilter(inst, item, owner)
- Description: Applies custom filtering rules for items eligible for pickup by Woby. Used as a predicate in
FindPickupableItem. - Parameters:
inst: The Woby entity instance.item: The item being evaluated.owner: The owner entity (typically Walter).
- Returns:
trueifitemmeets all criteria; otherwisefalseornil. - Error states: Returns
falseearly if:itemhas"outofreach"tag (e.g., cave_hole items),itemlacksinventoryitemor is not landed (is_landed ~= true),itemis a trap,itemhas physics active and collides withinst,itemis not on passable terrain or differs in platform,itemis within combat-runaway range (COMBAT_TOO_CLOSE_DIST) and Woby is fleeing.
DoPickUpAction(inst)
- Description: Attempts to construct a
BufferedActionto pick up the most suitable fetchable item for Woby. Prioritizes items by prefetch queue and distance. - Parameters:
inst: The Woby entity instance.
- Returns: A valid
BufferedActiontargeting the item and actionACTIONS.WOBY_PICKUP, ornilif no eligible item is found. - Error states: Returns
nilifFindPickupableItemfails to locate an item.
HasPickUpBehavior(inst)
- Description: Determines if Woby has the Walter + Woby Item Fetcher skill active.
- Parameters:
inst: The Woby entity instance.
- Returns:
trueifskilltreeupdater:IsActivated("walter_woby_itemfetcher")istrue; otherwisefalse.
IsAllowedToPickUp(inst)
- Description: Checks if Woby is currently permitted to pick up items based on player command state.
- Parameters:
inst: The Woby entity instance.
- Returns:
trueifinst.woby_commands_classified:ShouldPickup()returnstrue; otherwisefalse.
FetchingActionNode(inst)
- Description: Factory function returning a
WhileNodethat executesDoPickUpActioncontinuously whileIsAllowedToPickUpandHasPickUpBehaviorare both true. - Parameters:
inst: The Woby entity instance.
- Returns: A
WhileNodebehavior tree node configured for item fetching.
IsAllowedToRetrieveAmmo(inst)
- Description: Checks if Walter’s equipped hands item is a slingshot with recoverable ammo.
- Parameters:
inst: The Woby entity instance.
- Returns:
trueif the equippedHANDSitem has"slingshot"tag andcontainer:HasItemWithTag("recoverableammo", 1); otherwisefalse.
GetRecoverableAmmoPickUpAction(inst)
- Description: Constructs a
BufferedActionto retrieve recoverable ammo from the slingshot container or ground. - Parameters:
inst: The Woby entity instance.
- Returns: A
BufferedActionforACTIONS.WOBY_PICKUPon ammo, ornilif no ammo found.
ReturnRecoverableAmmoAction(inst)
- Description: Attempts to return recoverable ammo in Woby’s inventory to Walter.
- Parameters:
inst: The Woby entity instance.
- Returns: A
BufferedActionforACTIONS.GIVEALLTOPLAYER, ornilif:- no ammo in inventory,
- Walter’s inventory/trader cannot accept it,
- Walter is not currently opening/trading with Woby.
RetrieveAmmoNode(inst)
- Description: Behavior tree node that prioritizes returning ammo to Walter if close, otherwise fetching it, and falls back to returning if fetch fails.
- Parameters:
inst: The Woby entity instance.
- Returns: A
PriorityNodebehavior with logic:- If owner is near, try
ReturnRecoverableAmmoAction. - Else if allowed to pick up, try
GetRecoverableAmmoPickUpAction. - Fallback to
ReturnRecoverableAmmoAction.
- If owner is near, try
PickUpAmmoNode(inst)
- Description: Simplified node that only fetches recoverable ammo (without giving back). Used when retrieval is disabled but fetching remains.
- Parameters:
inst: The Woby entity instance.
- Returns: A
WhileNodeexecutingGetRecoverableAmmoPickUpActionwhen conditions met.
DoForagerAction(inst)
- Description: Attempts to forage using Woby’s configured forager target.
- Parameters:
inst: The Woby entity instance.
- Returns: A
BufferedActionforACTIONS.WOBY_PICK, ornilif no target.
HasForagingBehavior(inst)
- Description: Checks if Woby has the Walter + Woby Foraging skill active.
- Parameters:
inst: The Woby entity instance.
- Returns:
trueifskilltreeupdater:IsActivated("walter_woby_foraging")istrue.
IsAllowedToForager(inst)
- Description: Checks if Woby is permitted to forage per current player command.
- Parameters:
inst: The Woby entity instance.
- Returns:
trueifinst.woby_commands_classified:ShouldForage()istrue.
ForagerNode(inst)
- Description: Returns a
WhileNodeto drive foraging behavior when enabled and permitted. - Parameters:
inst: The Woby entity instance.
- Returns: A
WhileNodethat executesDoForagerActionunder appropriate conditions.
ShouldSit(inst)
- Description: Determines if Woby should be in a sitting state based on player command and delivery state.
- Parameters:
inst: The Woby entity instance.
- Returns:
trueifinst.woby_commands_classified:ShouldSit()istrueandoutfordeliveryis not active; otherwisefalse.
StartSitting(inst)
- Description: Pushes
"start_sitting"event to Woby ifShouldSitistrue. - Parameters:
inst: The Woby entity instance.
- Returns: Same as
ShouldSit.
KeepSitting(inst)
- Description: Maintains sitting state, adjusting for cowering (combat avoidance) and rotation. Pushes
"stop_sitting"or"start_sitting"as needed. - Parameters:
inst: The Woby entity instance.
- Returns: Boolean indicating whether Woby should continue sitting.
SitStillNode(inst)
- Description: Returns a
StandStillnode for sitting behavior with dynamic start/keep logic. - Parameters:
inst: The Woby entity instance.
- Returns: A
StandStillnode configured withStartSittingandKeepSitting.
CourierNode(inst)
- Description: Behavior tree node that handles courier delivery: moving to destination, sitting within leash range, and storing items in a valid container.
- Parameters:
inst: The Woby entity instance.
- Returns: A
WhileNodethat:- Checks for courier data,
- Enforces leash distance,
- Attempts
StoreItemActionwith wait.
StoreItemAction(inst)
- Description: Finds an item in Woby’s inventory and attempts to store it in a valid container using
WobyCourier_FindValidContainerForItem. - Parameters:
inst: The Woby entity instance.
- Returns: A
BufferedActionforACTIONS.STORE, ornilif no valid container found.
IsTryingToPerformAction(inst, performer, action)
- Description: Checks if the
performer(e.g., player) is actively attempting a specific action oninst. - Parameters:
inst: The Woby entity instance.performer: The entity performing the action.action: AnACTIONSenum value.
- Returns:
trueif the buffered or remote interaction action matches the givenaction.
TryingToInteractWithWoby(inst, performer)
- Description: Checks if
performeris attempting to feed, pet, rummage, store, or open the container oninst. - Parameters:
inst: The Woby entity instance.performer: The entity attempting interaction.
- Returns:
trueif any interaction action is in progress or container is open.
GetWalterInteractionFn(inst)
- Description: Returns
inst._playerlinkif Walter is currently interacting with Woby. - Parameters:
inst: The Woby entity instance.
- Returns:
inst._playerlinkifTryingToInteractWithWobyistrue; otherwisenil.
KeepGenericInteractionFn(inst, target)
- Description: Returns
trueiftargetis still interacting withinst. - Parameters:
inst: The Woby entity instance.target: The interacting entity.
- Returns: Same as
TryingToInteractWithWoby(inst, target).
WatchingMinigameNode(inst)
- Description: Behavior tree node that makes Woby watch a minigame (e.g., Battle Boar) while respecting distances and player wheel interaction.
- Parameters:
inst: The Woby entity instance.
- Returns: A
WhileNodewith priority:- If wheel is open, face the minigame.
- Otherwise, follow at minigame distances.
- Run away if in combat cower mode.
- Face minigame as fallback.
RecallNode(inst, follownode)
- Description: Handles Woby’s recall logic: returns to owner if summoned, with timeouts and fallback recall cancellation.
- Parameters:
inst: The Woby entity instance.follownode: Behavior node to run in parallel while recalled.
- Returns: A
WhileNodewith two fallback strategies:- Wait up to 10 seconds while following or staying near owner.
- Or wait 1.25 seconds and auto-cancel recall.
IsWheelOpen(inst)
- Description: Exposed at module scope for external reuse.
- Parameters:
inst: The Woby entity instance.
- Returns: Boolean indicating if the command wheel is open.
Events & listeners
This module does not register or push events directly. It invokes inst:PushEvent internally in StartSitting and KeepSitting ("start_sitting", "stop_sitting"), but only as part of behavior node execution — not as standalone event handlers.